diff --git a/CHANGELOG.md b/CHANGELOG.md index 16c2c3f68..780c18a11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ What a version number promises before 1.0 is described in [docs/VERSIONING.md](d ## [Unreleased] +### Added + +- **`dg board`.** List, view (`--view`, `--json` with the fold), create (the web's templates or `--columns`), move (`--top`, `--before`, `--after`), set fields, add (or open a new issue with `--title`), archive, remove, move to the next iteration, close and delete boards from the command line, private repositories' sealed boards and cards included ([Boards guide](docs/guides/boards.md)). forge-core reads and writes boards and cards as the web does, and runs the `sealed_board` vectors. +- **Board contract types.** forge-meta gains `board` and `card` (UPDATE-3, [boards design](docs/design/boards.md) §3), written only by the home repository's members; testnet got them on 2026-10-27 by an in-place update of forge-meta to version 3 ([evidence](forge-contracts/evidence/testnet/README.md#forge-meta-update-to-version-3-boards-2026-10-27)). + ### Fixed - **InstantSend proofs on testnet.** Creating or topping up an identity, in the web app or with `dg auth new`, waited on `getislocks` at `trpc.digitalcash.dev`, which no longer follows testnet, so every lock fell back to a slower chain-lock proof. The InstantSend lock now comes off DAPI `subscribeToTransactionsWithProofs` feeds on three evonodes, opened before the asset lock is broadcast, as in govhub and mainnet-bridge. `--islock-rpc` and `islock_rpc` still add an RPC of your choice, but none is set by default. diff --git a/crates/dg/src/board.rs b/crates/dg/src/board.rs new file mode 100644 index 000000000..ff1552a85 --- /dev/null +++ b/crates/dg/src/board.rs @@ -0,0 +1,1713 @@ +//! `dg board` — a repository's boards (`docs/design/boards.md` §6; forge-meta `board` and +//! `card`, UPDATE-3). Reads, item assembly and writes are forge-core's +//! (`forge_core::collab::boards`), the fold, rank, query and view rules +//! `forge_core::rules::boards`, shared with the web through the `board_*` vectors. +//! +//! An item is named `#12` (or `12`) in the board's home repository, `owner/name#12` in another, +//! and `pr#12` / `issue#12` where an issue and a pull request share a number. Every write is +//! one document per item, priced and confirmed first (`--yes` skips the prompt). + +use std::collections::{BTreeMap, HashMap}; + +use anyhow::Result; +use serde_json::{json, Value}; + +use crate::common::{Reader, Session}; +use crate::context::Ctx; +use crate::fmt::{cost_json, cost_line, plural}; +use crate::{BoardCommand, BoardTemplate}; +use forge_core::collab::boards::{ + cross_repo_card_needs_confirm, parse_item_reference, plan_card_writes, Board, BoardSnapshot, + BoardState, BulkWritten, CardItem, CardPatch, CardWritten, DropAt, CROSS_REPO_WARNING, +}; +use forge_core::collab::v2::Collab; +use forge_core::rules::boards::{ + column_totals, date_of, default_spec, group_rows, iteration_at, iteration_progress, + iteration_range, matches_board_query, monday_of, parse_board_query, repo_names_of, sort_rows, + sum_field_of, BoardColumn, BoardField, BoardItem, BoardRow, BoardSource, BoardSpec, BoardView, + FieldOption, FieldType, ItemKind, Placement, QueryContext, Scalar, SourceKind, ViewLayout, + CARD_ACTIVE, CARD_ARCHIVED, CARD_REMOVED, MAX_COLUMNS, +}; +use forge_core::scope::RepoRef; + +/// Dispatch a `board` subcommand. +pub async fn run(ctx: &Ctx, cmd: &BoardCommand) -> Result<()> { + match cmd { + BoardCommand::List { repo, deleted } => list(ctx, repo, *deleted).await, + BoardCommand::View { + repo, + board, + view, + archived, + } => Box::pin(show(ctx, repo, board, view.as_deref(), *archived)).await, + BoardCommand::Create { + repo, + name, + columns, + template, + } => create(ctx, repo, name, columns.as_deref(), *template).await, + BoardCommand::Move { + repo, + board, + item, + column, + top, + bottom: _, + before, + after, + } => { + let at = match (before, after) { + (Some(m), _) => Where::Before(m.clone()), + (_, Some(m)) => Where::After(m.clone()), + _ if *top => Where::Top, + _ => Where::Bottom, + }; + Box::pin(move_item(ctx, repo, board, item, column, at)).await + } + BoardCommand::Set { + repo, + board, + item, + values, + } => Box::pin(set(ctx, repo, board, item, values)).await, + BoardCommand::Add { + repo, + board, + items, + column, + title, + } => match title { + Some(t) => Box::pin(quick_add(ctx, repo, board, t, column.as_deref())).await, + None => Box::pin(bulk(ctx, repo, board, items, Bulk::Add(column.clone()))).await, + }, + BoardCommand::Archive { + repo, + board, + items, + restore, + } => { + let op = if *restore { + Bulk::Restore + } else { + Bulk::Archive + }; + Box::pin(bulk(ctx, repo, board, items, op)).await + } + BoardCommand::Remove { repo, board, items } => { + Box::pin(bulk(ctx, repo, board, items, Bulk::Remove)).await + } + BoardCommand::NextIteration { repo, board, field } => { + Box::pin(next_iteration(ctx, repo, board, field.as_deref())).await + } + BoardCommand::Close { + repo, + board, + reopen, + } => { + let state = if *reopen { + BoardState::Open + } else { + BoardState::Closed + }; + set_state(ctx, repo, board, state).await + } + BoardCommand::Delete { repo, board } => { + set_state(ctx, repo, board, BoardState::Deleted).await + } + } +} + +/// Now, in ms (the fold's `now`). +fn now_ms() -> i64 { + std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .map_or(0, |d| i64::try_from(d.as_millis()).unwrap_or(i64::MAX)) +} + +// --------------------------------------------------------------------------------------------- +// Arguments +// --------------------------------------------------------------------------------------------- + +/// `--columns "Todo,In progress,Done"`: trimmed names, none empty, at most 20. +fn parse_columns(s: &str) -> Result> { + let names: Vec = s.split(',').map(|n| n.trim().to_string()).collect(); + if names.iter().any(String::is_empty) { + return Err(crate::errors::usage(format!( + "--columns {s:?}: a column name is empty; separate names with commas, like \"Todo,In progress,Done\"" + ))); + } + if names.len() > MAX_COLUMNS { + return Err(crate::errors::usage(format!( + "--columns: a board has at most {MAX_COLUMNS} columns, not {}", + names.len() + ))); + } + Ok(names) +} + +/// The web's Priority field (P0–P3), as its templates define it. +fn priority_field() -> BoardField { + let option = |id, name: &str, color: &str| FieldOption { + id, + name: name.into(), + color: Some(color.into()), + }; + BoardField { + id: 1, + name: "Priority".into(), + kind: FieldType::Sel, + options: Some(vec![ + option(1, "P0", "#d1242f"), + option(2, "P1", "#fb8f44"), + option(3, "P2", "#d4a72c"), + option(4, "P3", "#8c959f"), + ]), + start: None, + days: None, + } +} + +/// A view with only its id, name, layout and filter. +fn view(id: u8, name: &str, layout: ViewLayout, q: &str) -> BoardView { + BoardView { + id, + name: name.into(), + layout, + q: q.into(), + group: None, + lane: None, + sort: None, + cols: None, + date: None, + } +} + +/// Columns 1…n named `names`. +fn columns_of>(names: impl IntoIterator) -> Vec { + names + .into_iter() + .enumerate() + .map(|(i, name)| BoardColumn { + id: u8::try_from(i + 1).unwrap_or(u8::MAX), + name: name.as_ref().to_string(), + color: None, + wip: None, + }) + .collect() +} + +/// `template`'s definition for a board of home repository `home` created at `now`, as the +/// web's create dialog writes it (`board-templates.ts`, parity). +fn template_spec(template: BoardTemplate, home: &str, now: i64) -> BoardSpec { + let source = |k, q: &str| BoardSource { + r: Some(home.to_string()), + k, + q: q.into(), + }; + let cols = |c: &[&str]| Some(c.iter().map(|s| (*s).to_string()).collect()); + match template { + BoardTemplate::Kanban => default_spec(home, now), + BoardTemplate::Sprint => BoardSpec { + v: 1, + desc: None, + columns: columns_of(["Backlog", "Todo", "In progress", "In review", "Done"]), + def: 1, + done: 5, + sources: vec![source(SourceKind::All, "")], + fields: vec![ + BoardField { + id: 1, + name: "Iteration".into(), + kind: FieldType::Iter, + options: None, + start: Some(monday_of(now)), + days: Some(14), + }, + BoardField { + id: 2, + name: "Estimate".into(), + kind: FieldType::Num, + options: None, + start: None, + days: None, + }, + ], + views: vec![ + view(1, "Board", ViewLayout::Board, ""), + view(2, "Current sprint", ViewLayout::Board, "iteration:@current"), + BoardView { + group: Some("f1".into()), + cols: cols(&["title", "status", "assignees", "f1", "f2"]), + ..view(3, "Table", ViewLayout::Table, "") + }, + BoardView { + date: Some(vec![1]), + ..view(4, "Roadmap", ViewLayout::Roadmap, "") + }, + ], + arch: 14, + }, + BoardTemplate::Triage => BoardSpec { + v: 1, + desc: None, + columns: columns_of(["Needs triage", "Confirmed", "In progress", "Fixed"]), + def: 1, + done: 4, + sources: vec![source(SourceKind::Issues, "label:bug")], + fields: vec![priority_field()], + views: vec![ + view(1, "Board", ViewLayout::Board, ""), + BoardView { + group: Some("f1".into()), + cols: cols(&["title", "status", "assignees", "labels", "f1"]), + ..view(2, "By priority", ViewLayout::Table, "is:open") + }, + ], + arch: 14, + }, + BoardTemplate::Empty => BoardSpec { + v: 1, + desc: None, + columns: columns_of(["Todo"]), + def: 1, + done: 0, + sources: Vec::new(), + fields: Vec::new(), + views: Vec::new(), + arch: 0, + }, + } +} + +/// A new board's definition: `template`'s for home repository `home` at `now`, its columns +/// replaced by `columns` when given (ids 1…n; the first is the default column, one named Done +/// the Done column). +pub(crate) fn spec_for( + template: BoardTemplate, + home: &str, + columns: Option<&str>, + now: i64, +) -> Result { + let mut spec = template_spec(template, home, now); + if let Some(cols) = columns { + spec.columns = columns_of(parse_columns(cols)?); + spec.def = 1; + spec.done = spec + .columns + .iter() + .find(|c| c.name.eq_ignore_ascii_case("done")) + .map_or(0, |c| c.id); + } + Ok(spec) +} + +/// An item as typed: its kind when `pr#12` / `issue#12` says it, its repository when +/// `owner/name#12` names one, and its number. +#[derive(Debug, Clone, PartialEq, Eq)] +struct ItemArg { + kind: Option, + repo: Option, + number: u32, +} + +/// `#12`, `12`, `owner/name#12`, a link of the web app, or any of the first three with `pr` or +/// `issue` before the `#`. +fn parse_item_arg(s: &str) -> Result { + let t = s.trim(); + let lower = t.to_ascii_lowercase(); + let (kind, rest) = if let Some(r) = lower.strip_prefix("pr#") { + (Some(ItemKind::Pr), format!("#{}", &t[t.len() - r.len()..])) + } else if let Some(r) = lower.strip_prefix("issue#") { + ( + Some(ItemKind::Issue), + format!("#{}", &t[t.len() - r.len()..]), + ) + } else if !t.is_empty() && t.bytes().all(|b| b.is_ascii_digit()) { + (None, format!("#{t}")) + } else { + (None, t.to_string()) + }; + let Some(r) = parse_item_reference(&rest) else { + return Err(crate::errors::usage(format!( + "{:?} is not an issue or pull request: write #12, owner/name#12, or pr#12 for a pull request", + crate::fmt::safe(s) + ))); + }; + Ok(ItemArg { + kind, + repo: r.repo.map(|(o, n)| format!("{o}/{n}")), + number: r.number, + }) +} + +/// Column `name` of `spec` (case-insensitive), or its id. `none` / `No status` is 0 only on a +/// board whose default column is "No status" (`def` 0): elsewhere a card without a column +/// shows in the default column (§2.4), so moving one there would say one thing and do another. +fn find_column(spec: &BoardSpec, name: &str) -> Option { + let n = name.trim(); + if n.eq_ignore_ascii_case("none") || n.eq_ignore_ascii_case("no status") { + return (spec.def == 0).then_some(0); + } + spec.columns + .iter() + .find(|c| c.name.to_lowercase() == n.to_lowercase()) + .or_else(|| { + spec.columns + .iter() + .find(|c| n.parse::().ok() == Some(c.id)) + }) + .map(|c| c.id) +} + +fn column_name(spec: &BoardSpec, id: u8) -> String { + spec.columns + .iter() + .find(|c| c.id == id) + .map_or_else(|| "No status".to_string(), |c| c.name.clone()) +} + +/// The names of `spec`'s columns, in order. +fn column_names(spec: &BoardSpec) -> Vec { + spec.columns.iter().map(|c| c.name.clone()).collect() +} + +/// How a board is named in prompts and output. +fn board_name(b: &Board) -> &str { + b.name.as_deref().unwrap_or("(sealed)") +} + +fn no_column(spec: &BoardSpec, name: &str) -> anyhow::Error { + let names: Vec = column_names(spec) + .iter() + .map(|n| format!("{n:?}")) + .collect(); + crate::errors::usage(format!( + "this board has no column {name:?}; its columns are {}", + crate::fmt::join_and(&names) + )) +} + +/// Field `name` of `spec` (case-insensitive). +fn find_field<'s>(spec: &'s BoardSpec, name: &str) -> Option<&'s BoardField> { + let n = name.trim().to_lowercase(); + spec.fields.iter().find(|f| f.name.to_lowercase() == n) +} + +/// `raw` as a value of `field` at `now`: `None` clears it (an empty value). A select takes an +/// option's name, a number a number, a date `YYYY-MM-DD` or `@today`, an iteration `@current`, +/// `@next`, `@previous`, `3` or `Iteration 3`, a text field anything. The board rules judge the +/// result again before anything is signed. +fn parse_value(field: &BoardField, raw: &str, now: i64) -> Result> { + let v = raw.trim(); + if v.is_empty() { + return Ok(None); + } + let bad = |why: &str| { + crate::errors::usage(format!( + "{v:?} is not a value of {}: {why}", + crate::fmt::safe(&field.name) + )) + }; + Ok(Some(match field.kind { + FieldType::Sel => { + let options = field.options.as_deref().unwrap_or_default(); + let o = options + .iter() + .find(|o| o.name.to_lowercase() == v.to_lowercase()) + .ok_or_else(|| { + let names: Vec = + options.iter().map(|o| format!("{:?}", o.name)).collect(); + bad(&format!("pick one of {}", crate::fmt::join_and(&names))) + })?; + Scalar::from(i64::from(o.id)) + } + FieldType::Num => Scalar::Num( + v.parse::() + .ok() + .filter(|x| x.is_finite()) + .ok_or_else(|| bad("a number"))?, + ), + FieldType::Date if v.eq_ignore_ascii_case("@today") => Scalar::Text(date_of(now)), + FieldType::Date => { + if forge_core::rules::boards::date_days(v).is_none() { + return Err(bad("a date, YYYY-MM-DD")); + } + Scalar::Text(v.to_string()) + } + FieldType::Iter => { + let current = iteration_at(field, now); + let lower = v.to_lowercase(); + let k = match lower.as_str() { + "@current" => current, + "@next" => Some(current.map_or(0, |c| c + 1)), + "@previous" => current.filter(|c| *c > 0).map(|c| c - 1), + _ => { + let prefix = format!("{} ", field.name.to_lowercase()); + let n = lower.strip_prefix(&prefix).unwrap_or(&lower); + n.parse::().ok().filter(|n| *n >= 1).map(|n| n - 1) + } + }; + Scalar::from(k.ok_or_else(|| { + bad("an iteration: @current, @next, @previous, or its number (3, or \"Iteration 3\")") + })?) + } + FieldType::Text => Scalar::Text(v.to_string()), + })) +} + +/// `field=value` pairs as one card patch: fields by name (`status=` moves the card). +fn parse_assignments(spec: &BoardSpec, values: &[String], now: i64) -> Result { + let mut patch = CardPatch::default(); + for pair in values { + let Some((key, raw)) = pair.split_once('=') else { + return Err(crate::errors::usage(format!( + "{pair:?}: write field=value (an empty value clears the field)" + ))); + }; + if key.trim().eq_ignore_ascii_case("status") { + patch.col = Some(find_column(spec, raw).ok_or_else(|| no_column(spec, raw))?); + continue; + } + let Some(field) = find_field(spec, key) else { + let names: Vec = spec + .fields + .iter() + .map(|f| format!("{:?}", f.name)) + .collect(); + return Err(crate::errors::usage(if names.is_empty() { + format!("this board has no field {key:?} (it has no fields)") + } else { + format!( + "this board has no field {key:?}; its fields are {}", + crate::fmt::join_and(&names) + ) + })); + }; + patch.fields.insert(field.id, parse_value(field, raw, now)?); + } + Ok(patch) +} + +/// How a field's value reads: an option's name, an iteration's name, a number as the web +/// prints it, the text. +fn value_text(field: &BoardField, v: &Scalar) -> String { + let n = serde_json::to_value(v).ok(); + let as_int = n.as_ref().and_then(Value::as_i64); + match field.kind { + FieldType::Sel => field + .options + .as_deref() + .unwrap_or_default() + .iter() + .find(|o| Some(i64::from(o.id)) == as_int) + .map_or_else(String::new, |o| o.name.clone()), + FieldType::Iter => as_int + .and_then(|k| iteration_range(field, k)) + .map_or_else(String::new, |r| r.name), + _ => match n { + Some(Value::String(s)) => s, + Some(other) => other.to_string(), + None => String::new(), + }, + } +} + +/// An item's field values by field name, as they read. +fn named_fields(spec: &BoardSpec, p: &Placement) -> BTreeMap { + p.fields + .iter() + .filter_map(|(id, v)| spec.field(*id).map(|f| (f.name.clone(), value_text(f, v)))) + .collect() +} + +/// How an item is named: `#12` in the home repository (`repo` `None`), `owner/name #12` +/// elsewhere; a pull request with `pr`. +fn ref_label(kind: ItemKind, repo: Option<&str>, number: u64) -> String { + let prefix = if kind == ItemKind::Pr { "pr" } else { "" }; + match repo { + None => format!("{prefix}#{number}"), + Some(r) => format!("{r} {prefix}#{number}"), + } +} + +/// [`ref_label`] of a board item; "a private item" for a placeholder. +fn item_label(item: &BoardItem, home: &str) -> String { + if item.number == 0 { + return "a private item".into(); + } + let repo = (item.repo_id != home).then(|| item.repo.as_deref().unwrap_or(&item.repo_id)); + ref_label(item.kind, repo, item.number) +} + +// --------------------------------------------------------------------------------------------- +// Resolving +// --------------------------------------------------------------------------------------------- + +/// The board `arg` names in `repo`: its number (key) or its name (case-insensitive). +async fn find_board(collab: &Collab<'_>, repo: &RepoRef, arg: &str) -> Result { + let listed = || format!("`dg board list {}` lists its boards", repo.display()); + if let Ok(key) = arg.trim().parse::() { + if let Some(b) = collab.board_definition(repo, key).await? { + if b.state != BoardState::Deleted { + return Ok(b); + } + } + } + let boards = collab.boards(repo, false).await?; + let found: Vec<&Board> = boards + .iter() + .filter(|b| { + b.name + .as_deref() + .is_some_and(|n| n.to_lowercase() == arg.trim().to_lowercase()) + }) + .collect(); + match found.as_slice() { + [one] => Ok((*one).clone()), + [] => Err(crate::errors::not_found( + format!("no board {:?} in {}", crate::fmt::safe(arg), repo.display()), + listed(), + )), + many => Err(crate::errors::usage(format!( + "{} boards in {} are named {:?}: name one by its number ({})", + many.len(), + repo.display(), + crate::fmt::safe(arg), + many.iter() + .map(|b| b.key.to_string()) + .collect::>() + .join(", ") + ))), + } +} + +/// The board's snapshot now, or E102. +async fn snapshot(collab: &Collab<'_>, repo: &RepoRef, board: &Board) -> Result { + collab + .board_snapshot(repo, board.key, now_ms(), false) + .await? + .ok_or_else(|| { + crate::errors::not_found( + format!( + "board {} of {} has no definition", + board.key, + repo.display() + ), + format!("`dg board list {}` lists its boards", repo.display()), + ) + }) +} + +/// The item `arg` names, on the board or not: one of the board's items with that number (and +/// repository, and kind), else issue (then pull request) `number` of its repository. +async fn find_item( + collab: &Collab<'_>, + s: &Session, + snap: &BoardSnapshot, + arg: &str, +) -> Result<(CardItem, String)> { + let a = parse_item_arg(arg)?; + let repo = match &a.repo { + None => s.repo.clone(), + Some(r) => { + let parsed = crate::common::RepoRef::parse(r)?; + crate::common::resolve(&s.client, &s.identity, &parsed).await? + } + }; + let on: Vec<&BoardItem> = snap + .items + .items + .iter() + .filter(|i| { + i.repo_id == repo.id() + && i.number == u64::from(a.number) + && a.kind.is_none_or(|k| k == i.kind) + }) + .collect(); + match on.as_slice() { + [one] => return Ok((CardItem::of(one), item_label(one, s.repo.id()))), + [_, _, ..] => { + return Err(crate::errors::usage(format!( + "issue #{n} and pull request #{n} are both on this board: write issue#{n} or pr#{n}", + n = a.number + ))) + } + [] => {} + } + let Some((id, kind)) = collab + .resolve_item_by_number(&repo, a.number, a.kind) + .await? + else { + return Err(crate::errors::not_found( + format!( + "no issue or pull request #{} in {}", + a.number, + repo.display() + ), + format!("`dg issue list {}` lists its issues", repo.display()), + )); + }; + let display = repo.display(); + let label = ref_label( + kind, + (repo.id() != s.repo.id()).then_some(display.as_str()), + u64::from(a.number), + ); + Ok(( + CardItem { + id, + repo_id: repo.id().to_string(), + }, + label, + )) +} + +/// The end of a write's prompt: the warning when it publishes that a private board tracks +/// another repository's items (§3.3), and the closing parenthesis. +fn cross_repo_suffix(home: &RepoRef, items: &[CardItem]) -> String { + if items + .iter() + .any(|i| cross_repo_card_needs_confirm(home, &i.repo_id)) + { + format!(". Note: {CROSS_REPO_WARNING})") + } else { + ")".into() + } +} + +/// The estimated price of card writes for `ids` on `snap`'s board: a create for each item the +/// signer has no card for, a replace for the rest. +fn card_quote(s: &Session, snap: &BoardSnapshot, ids: &[String]) -> u64 { + let (creates, replaces) = plan_card_writes(&snap.read.cards, &s.identity.id(), ids); + crate::quote::card_writes(creates, replaces, card_bytes(&s.repo)) +} + +/// What every card command starts with: a session for writing, the board `board` names (open), +/// and its definition. +async fn open_board( + ctx: &Ctx, + repo: &str, + board: &str, + refusal: &str, +) -> Result<(Session, Board, BoardSpec)> { + let s = Session::open_for_write(ctx, repo, refusal).await?; + let b = find_board(&s.collab(), &s.repo, board).await?; + require_open(&b)?; + let spec = spec_of(&b)?.clone(); + Ok((s, b, spec)) +} + +/// The bytes a card write stores beyond its fixed shape (the web's `BOARD_WRITE_BYTES.card`), +/// sealed ones with their framing. +fn card_bytes(repo: &RepoRef) -> u64 { + if repo.visibility == forge_core::rules::v2::Visibility::Private { + 40 + 29 + 32 + } else { + 40 + } +} + +/// Refuse a board that is not open before anything is priced. +fn require_open(board: &Board) -> Result<()> { + match board.state { + BoardState::Open => Ok(()), + BoardState::Closed => Err(crate::errors::usage(format!( + "board {} is closed: reopen it with `dg board close {} --reopen` to change it", + board.key, board.key + ))), + BoardState::Deleted => Err(crate::errors::usage(format!( + "board {} was deleted", + board.key + ))), + } +} + +/// The board's definition, or the refusal that it did not open here. +fn spec_of(board: &Board) -> Result<&BoardSpec> { + board.spec.as_ref().ok_or_else(|| { + crate::errors::usage(format!( + "board {}'s definition can't be read here ({})", + board.key, + board.spec_error.as_deref().unwrap_or("unreadable") + )) + }) +} + +// --------------------------------------------------------------------------------------------- +// JSON +// --------------------------------------------------------------------------------------------- + +/// A board as `list` and `view` print it. +fn board_json(b: &Board) -> Value { + json!({ + "key": b.key, + "name": b.name, + "state": b.state.as_str(), + "sealed": b.sealed, + "repoId": b.repo_id, + "columns": b.spec.as_ref().map(column_names), + "specError": b.spec_error, + "updatedAt": b.newest.updated_at, + "editedBy": b.newest.owner_id, + }) +} + +pub(crate) fn list_json(boards: &[Board]) -> Value { + json!({ + "count": boards.len(), + "boards": boards.iter().map(board_json).collect::>(), + }) +} + +/// One group of a shown board: its label, its items in shown order, its totals. +struct Group { + key: Value, + name: String, + items: Vec, + count: usize, + sum: Option, + wip: Option, + over: bool, +} + +/// What `view` shows: the groups (the columns, or the view's grouping) of the items that pass +/// the view's filter, in its sort, with totals and WIP. +pub(crate) struct Shown { + view: Option, + group_by: String, + sum_field: Option, + groups: Vec, + unresolved: Vec, + ids: Vec, +} + +/// The query view `view` (`None`: every item) filters by, with `is:archived` when asked for. +fn view_query(view: Option<&BoardView>, archived: bool) -> String { + let mut q = view.map_or_else(String::new, |v| v.q.clone()); + if archived { + q.push_str(" is:archived"); + } + q +} + +/// The repository ids the `repo:` names of query `q` resolve to (§4.4, [`repo_names_of`]): +/// `owner/name` (the owner an identity id or a DPNS name) or a bare name of `home`'s owner, as +/// the web resolves them. A name that names no repository is left out (the query reports it). +async fn resolve_repo_names( + client: &forge_core::platform::PlatformClient, + home: &RepoRef, + q: &str, +) -> Result> { + use forge_core::Error; + let mut out = HashMap::new(); + for name in repo_names_of(q) { + let found = match name.split_once('/') { + Some((owner, repo)) => forge_core::resolve::resolve_named(client, owner, repo).await, + None => forge_core::resolve::resolve_named(client, home.owner_id(), &name).await, + }; + match found { + Ok(r) => { + out.insert(name, r.id().to_string()); + } + Err(Error::NotFound | Error::User(_) | Error::Config(_)) => {} + Err(e) => return Err(e.into()), + } + } + Ok(out) +} + +/// The groups of `snap` as view `view` (`None`: the board's columns, every item) shows them; +/// `repos` are the ids its `repo:` names resolved to ([`resolve_repo_names`]). +pub(crate) fn shown( + snap: &BoardSnapshot, + spec: &BoardSpec, + view: Option<&BoardView>, + archived: bool, + me: Option<&str>, + repos: &HashMap, +) -> Shown { + let placements = snap.placement_index(); + let q = view_query(view, archived); + let query = parse_board_query(&q, spec, repos); + let ctx = QueryContext { + me: me.map(str::to_string), + now: snap.now, + }; + let rows: Vec> = snap + .items + .items + .iter() + .filter_map(|i| { + let p = placements.get(i.id.as_str())?; + matches_board_query(i, p, spec, &query, &ctx).then_some(BoardRow { + item: i, + placement: p, + }) + }) + .collect(); + let rows = sort_rows(&rows, view.and_then(|v| v.sort.as_deref()), spec); + let group_by = view + .filter(|v| v.layout == ViewLayout::Board) + .and_then(|v| v.group.clone()) + .unwrap_or_else(|| "status".into()); + let sum_field = sum_field_of(spec, view); + let by_id: BTreeMap<&str, BoardRow<'_>> = + rows.iter().map(|r| (r.item.id.as_str(), *r)).collect(); + let wip: BTreeMap, bool)> = column_totals(&rows, spec, sum_field) + .into_iter() + .map(|t| (t.id, (t.wip, t.over))) + .collect(); + let field = forge_core::rules::boards::field_key_id(&group_by).and_then(|id| spec.field(id)); + let groups = group_rows(&rows, &group_by, spec, snap.now) + .into_iter() + .map(|g| { + let in_group: Vec> = g + .items + .iter() + .filter_map(|id| by_id.get(id.as_str()).copied()) + .collect(); + let t = forge_core::rules::boards::totals(&in_group, sum_field); + let key = serde_json::to_value(&g.key).unwrap_or(Value::Null); + let name = match (&g.key, group_by.as_str(), field) { + (None, "status", _) => "No status".to_string(), + (None, k, Some(f)) if k.starts_with('f') => format!("No {}", f.name), + (None, k, _) => format!("No {k}"), + (Some(_), "status", _) => column_name( + spec, + key.as_u64().and_then(|n| u8::try_from(n).ok()).unwrap_or(0), + ), + (Some(k), _, Some(f)) => value_text(f, k), + (Some(_), _, None) => match &key { + Value::String(s) => s.clone(), + other => other.to_string(), + }, + }; + let (wip, over) = if group_by == "status" { + key.as_u64() + .and_then(|n| u8::try_from(n).ok()) + .and_then(|id| wip.get(&id).copied()) + .unwrap_or((None, false)) + } else { + (None, false) + }; + Group { + key, + name, + items: g.items, + count: t.count, + sum: t.sum, + wip, + over, + } + }) + .collect(); + Shown { + view: view.cloned(), + group_by, + sum_field, + groups, + unresolved: query.unresolved, + ids: rows.iter().map(|r| r.item.id.clone()).collect(), + } +} + +/// The current iteration's progress of `spec`'s first iteration field (§4.5), as JSON. +fn progress_json(snap: &BoardSnapshot, spec: &BoardSpec, sum_field: Option) -> Value { + let Some(field) = spec.fields.iter().find(|f| f.kind == FieldType::Iter) else { + return Value::Null; + }; + let Some(k) = iteration_at(field, snap.now) else { + return Value::Null; + }; + let placements = snap.placement_index(); + let rows: Vec> = snap + .items + .items + .iter() + .filter_map(|i| { + let p = placements.get(i.id.as_str())?; + (p.on && p.archived.is_none()).then_some(BoardRow { + item: i, + placement: p, + }) + }) + .collect(); + let p = iteration_progress(&rows, spec, field.id, k, sum_field); + json!({ + "field": field.name, + "iteration": iteration_range(field, k), + "total": p.total, + "done": p.done, + "points": p.points, + "donePoints": p.done_points, + }) +} + +/// `dg board view --json`: the board, the groups shown, every item with its placement, and the +/// fold itself. +pub(crate) fn view_json(snap: &BoardSnapshot, s: &Shown) -> Value { + let board = &snap.read.board; + let spec = board.spec.as_ref(); + let placements = snap.placement_index(); + let items: Vec = snap + .items + .items + .iter() + .map(|i| { + let p = placements.get(i.id.as_str()); + json!({ + "id": i.id, + "number": i.number, + "repoId": i.repo_id, + "repo": i.repo, + "kind": i.kind, + "state": i.state, + "title": i.title, + "labels": i.labels, + "assignees": i.assignees, + "milestone": i.milestone, + "author": i.author, + "closedAt": i.closed_at, + "hidden": snap.items.hidden.contains(&i.id), + "on": p.is_some_and(|p| p.on), + "shown": s.ids.contains(&i.id), + "column": p.and_then(|p| spec.map(|sp| column_name(sp, p.col))), + "col": p.map(|p| p.col), + "rank": p.map(|p| p.rank.clone()), + "archived": p.and_then(|p| p.archived), + "removed": p.is_some_and(|p| p.removed), + "fields": match (spec, p) { + (Some(sp), Some(p)) => json!(named_fields(sp, p)), + _ => json!({}), + }, + }) + }) + .collect(); + json!({ + "board": board_json(board), + "view": s.view.as_ref().map(|v| v.name.clone()), + "groupBy": s.group_by, + "sumField": s.sum_field.and_then(|id| spec.and_then(|sp| sp.field(id)).map(|f| f.name.clone())), + "now": snap.now, + "columns": s.groups.iter().map(|g| json!({ + "key": g.key, + "name": g.name, + "count": g.count, + "sum": g.sum, + "wip": g.wip, + "over": g.over, + "items": g.items, + })).collect::>(), + "items": items, + "progress": spec.map_or(Value::Null, |sp| progress_json(snap, sp, s.sum_field)), + "unresolved": s.unresolved, + "hidden": snap.items.hidden, + "missing": snap.items.missing, + "partial": snap.items.partial, + "hasOlderClosed": snap.items.has_older_closed, + "fold": snap.fold, + }) +} + +/// One card write as the commands print it. +pub(crate) fn card_json(w: &CardWritten, label: &str) -> Value { + json!({ + "item": w.item, + "label": label, + "documentId": w.document_id, + "created": w.created, + "changed": w.changed, + "col": w.col, + "rank": w.rank, + "state": match w.state { + CARD_ARCHIVED => "archived", + CARD_REMOVED => "removed", + _ => "active", + }, + }) +} + +// --------------------------------------------------------------------------------------------- +// Reads +// --------------------------------------------------------------------------------------------- + +async fn list(ctx: &Ctx, repo: &str, deleted: bool) -> Result<()> { + let r = Reader::open(ctx, repo).await?; + let boards = r.collab().boards(&r.repo, deleted).await?; + ctx.emit(list_json(&boards), || { + if boards.is_empty() { + println!( + "no boards in {} (create one with `dg board create {repo} --name `)", + r.repo.display() + ); + } + for b in &boards { + let cols = b.spec.as_ref().map_or_else( + || "definition unreadable".to_string(), + |s| { + s.columns + .iter() + .map(|c| c.name.clone()) + .collect::>() + .join(" → ") + }, + ); + println!( + "{:<10} {:<30} {:<7} {cols}", + b.key, + crate::fmt::safe(board_name(b)), + b.state.as_str() + ); + } + }); + Ok(()) +} + +/// The view of `spec` named `name` (any case), or the refusal listing its views. +fn find_view(spec: &BoardSpec, name: &str) -> Result { + spec.views + .iter() + .find(|v| v.name.to_lowercase() == name.trim().to_lowercase()) + .cloned() + .ok_or_else(|| { + let names: Vec = spec.views.iter().map(|v| format!("{:?}", v.name)).collect(); + crate::errors::usage(format!( + "this board has no view {name:?}{}", + if names.is_empty() { + String::new() + } else { + format!("; its views are {}", crate::fmt::join_and(&names)) + } + )) + }) +} + +async fn show( + ctx: &Ctx, + repo: &str, + board: &str, + view: Option<&str>, + archived: bool, +) -> Result<()> { + let r = Reader::open_discussion(ctx, repo).await?; + let collab = r.collab(); + let b = find_board(&collab, &r.repo, board).await?; + let chosen = match view { + None => None, + Some(name) => Some(find_view(spec_of(&b)?, name)?), + }; + let q = view_query(chosen.as_ref(), archived); + // a view asking for archived items reads the older closed ones too, as the web's does + let asks_archived = parse_board_query(&q, spec_of(&b)?, &HashMap::new()) + .preds + .iter() + .any(|p| p.k == "is" && p.v == Some(Scalar::Text("archived".into()))); + let Some(snap) = collab + .board_snapshot(&r.repo, b.key, now_ms(), asks_archived) + .await? + else { + return Err(crate::errors::not_found( + format!("no board {board:?} in {}", r.repo.display()), + format!("`dg board list {repo}` lists its boards"), + )); + }; + // the definition as the snapshot read it (a member may have saved it a moment ago) + let spec = spec_of(&snap.read.board)?.clone(); + let chosen = match view { + None => None, + Some(name) => Some(find_view(&spec, name)?), + }; + let repos = resolve_repo_names(&r.client, &r.repo, &q).await?; + let shown = shown(&snap, &spec, chosen.as_ref(), archived, r.viewer(), &repos); + ctx.emit(view_json(&snap, &shown), || { + print_board(&snap, &spec, &shown); + }); + Ok(()) +} + +#[allow(clippy::too_many_lines)] // each group, then the progress and the notes +fn print_board(snap: &BoardSnapshot, spec: &BoardSpec, s: &Shown) { + let b = &snap.read.board; + let home = &b.repo_id; + let sum_name = s + .sum_field + .and_then(|id| spec.field(id)) + .map(|f| f.name.clone()); + println!( + "{} · board {} · {}{}", + crate::fmt::safe(board_name(b)), + b.key, + b.state.as_str(), + s.view + .as_ref() + .map_or_else(String::new, |v| format!(" · view {:?}", v.name)) + ); + let by_id: BTreeMap<&str, &BoardItem> = snap + .items + .items + .iter() + .map(|i| (i.id.as_str(), i)) + .collect(); + let placements = snap.placement_index(); + for g in &s.groups { + let mut head = format!( + "{} · {}", + crate::fmt::safe(&g.name), + plural(g.count, "item") + ); + if let (Some(sum), Some(name)) = (&g.sum, &sum_name) { + let _ = std::fmt::Write::write_fmt( + &mut head, + format_args!( + " · {name} {}", + serde_json::to_value(sum) + .map(|v| v.to_string()) + .unwrap_or_default() + ), + ); + } + if let Some(w) = g.wip { + let over = if g.over { " (over the limit)" } else { "" }; + let _ = + std::fmt::Write::write_fmt(&mut head, format_args!(" · WIP {}/{w}{over}", g.count)); + } + println!("\n── {head}"); + for id in &g.items { + let (Some(item), Some(p)) = (by_id.get(id.as_str()), placements.get(id.as_str())) + else { + continue; + }; + let state = match item.state { + forge_core::rules::boards::ItemState::Open => "", + forge_core::rules::boards::ItemState::Closed => " (closed)", + forge_core::rules::boards::ItemState::Merged => " (merged)", + }; + let fields = named_fields(spec, p) + .into_iter() + .map(|(k, v)| format!("{k}: {v}")) + .collect::>() + .join(" · "); + let archived = if p.archived.is_some() { + " [archived]" + } else { + "" + }; + println!( + " {:<8} {}{state}{archived}{}", + item_label(item, home), + crate::fmt::safe(&item.title), + if fields.is_empty() { + String::new() + } else { + format!(" [{}]", crate::fmt::safe(&fields)) + } + ); + } + } + if let Value::Object(p) = progress_json(snap, spec, s.sum_field) { + println!( + "\n{} {}: {}/{} done", + p["field"].as_str().unwrap_or_default(), + p["iteration"]["name"].as_str().unwrap_or_default(), + p["done"], + p["total"] + ); + } + if !s.unresolved.is_empty() { + eprintln!( + "note: the view's filter names what this board does not have: {}", + s.unresolved.join(", ") + ); + } + if snap.items.partial { + eprintln!( + "note: only the newest {} pull requests of a source repository are read", + forge_core::collab::boards::PR_PAGES * 100 + ); + } + if snap.items.has_older_closed { + eprintln!( + "note: older closed items are left out (as the web's board does until \"Show older\")" + ); + } +} + +// --------------------------------------------------------------------------------------------- +// Writes +// --------------------------------------------------------------------------------------------- + +async fn create( + ctx: &Ctx, + repo: &str, + name: &str, + columns: Option<&str>, + template: BoardTemplate, +) -> Result<()> { + let s = Session::open_for_write(ctx, repo, "board not created").await?; + let spec = spec_for(template, s.repo.id(), columns, now_ms())?; + let collab = s.collab(); + let fields = forge_core::collab::boards::check_board_input(name, &spec)?; + let price = ctx.fiat_price(); + let quote = crate::quote::board_create((fields.name.len() + fields.spec.len()) as u64); + ctx.confirm_or_cancel(&format!( + "Create board {:?} in {} with columns {}? (one document, {} estimated; maintainers and writers)", + fields.name, + s.repo.display(), + column_names(&spec).join(", "), + cost_line(quote, price) + ))?; + // The create's intent (the web's `newBoardKey`): the name and definition, so running the + // same create again after its result was lost names the same board and makes no second one. + let intent = format!("{}\u{0}{}", fields.name, fields.spec); + let (w, spent) = s + .metered(|| collab.create_board(&s.repo, &fields.name, &spec, Some(&intent))) + .await?; + let status = if w.created { "created" } else { "exists" }; + ctx.emit( + json!({ + "status": status, + "key": w.key, + "name": fields.name, + "documentId": w.document_id, + "id": w.document_id, + "columns": column_names(&spec), + "cost": cost_json(spent, price), + }), + || { + let what = if w.created { + "created" + } else { + "already created by an earlier run" + }; + println!( + "✓ board {} {what}: number {} · {}", + fields.name, + w.key, + cost_line(spent, price) + ); + println!(" dg board view {repo} {}", w.key); + }, + ); + Ok(()) +} + +async fn set_state(ctx: &Ctx, repo: &str, board: &str, state: BoardState) -> Result<()> { + let s = Session::open_for_write(ctx, repo, "board not changed").await?; + let collab = s.collab(); + let b = find_board(&collab, &s.repo, board).await?; + let price = ctx.fiat_price(); + let own = forge_core::collab::boards::own_revision(&b, &s.identity.id()).is_some(); + let bytes = b + .spec + .as_ref() + .and_then(|sp| forge_core::rules::boards::serialize_spec(sp).ok()) + .map_or(0, |j| j.len()) as u64; + let quote = if own { + crate::quote::board_replace(bytes) + } else { + crate::quote::board_create(bytes) + }; + let (verb, status) = match state { + BoardState::Open => ("Reopen", "reopened"), + BoardState::Closed => ("Close", "closed"), + BoardState::Deleted => ("Delete", "deleted"), + }; + ctx.confirm_or_cancel(&format!( + "{verb} board {:?} ({}) in {}? (one document, {} estimated)", + board_name(&b), + b.key, + s.repo.display(), + cost_line(quote, price) + ))?; + let (w, spent) = s + .metered(|| collab.set_board_state(&s.repo, b.key, state)) + .await?; + ctx.emit( + json!({ + "status": status, + "key": b.key, + "documentId": w.document_id, + "changed": w.changed, + "cost": cost_json(spent, price), + }), + || println!("✓ board {} {status} · {}", b.key, cost_line(spent, price)), + ); + Ok(()) +} + +/// Where `move` puts the card, as typed. +enum Where { + Top, + Bottom, + Before(String), + After(String), +} + +async fn move_item( + ctx: &Ctx, + repo: &str, + board: &str, + item: &str, + column: &str, + at: Where, +) -> Result<()> { + let (s, b, spec) = open_board(ctx, repo, board, "board not changed").await?; + let collab = s.collab(); + let col = find_column(&spec, column).ok_or_else(|| no_column(&spec, column))?; + let snap = snapshot(&collab, &s.repo, &b).await?; + let (target, label) = find_item(&collab, &s, &snap, item).await?; + let drop = match at { + Where::Top => DropAt::Top, + Where::Bottom => DropAt::Bottom, + Where::Before(m) => DropAt::Before(find_item(&collab, &s, &snap, &m).await?.0.id), + Where::After(m) => DropAt::After(find_item(&collab, &s, &snap, &m).await?.0.id), + }; + let column_cards = snap.column(col); + let price = ctx.fiat_price(); + let quote = card_quote(&s, &snap, std::slice::from_ref(&target.id)); + ctx.confirm_or_cancel(&format!( + "Move {label} to {:?} on board {:?}? (one document, {} estimated{}", + column_name(&spec, col), + board_name(&b), + cost_line(quote, price), + cross_repo_suffix(&s.repo, std::slice::from_ref(&target)) + ))?; + let (w, spent) = s + .metered(|| collab.move_card(&s.repo, &b, &target, col, &column_cards, &drop, true)) + .await?; + ctx.emit( + json!({ + "status": "moved", + "board": b.key, + "column": column_name(&spec, col), + "card": card_json(&w, &label), + "cost": cost_json(spent, price), + }), + || { + println!( + "✓ {label} moved to {} · {}", + column_name(&spec, col), + cost_line(spent, price) + ); + }, + ); + Ok(()) +} + +async fn set(ctx: &Ctx, repo: &str, board: &str, item: &str, values: &[String]) -> Result<()> { + let (s, b, spec) = open_board(ctx, repo, board, "board not changed").await?; + let collab = s.collab(); + let patch = parse_assignments(&spec, values, now_ms())?; + let snap = snapshot(&collab, &s.repo, &b).await?; + let (target, label) = find_item(&collab, &s, &snap, item).await?; + let price = ctx.fiat_price(); + let quote = card_quote(&s, &snap, std::slice::from_ref(&target.id)); + ctx.confirm_or_cancel(&format!( + "Set {} on {label} on board {:?}? (one document, {} estimated{}", + values.join(" "), + board_name(&b), + cost_line(quote, price), + cross_repo_suffix(&s.repo, std::slice::from_ref(&target)) + ))?; + let (w, spent) = s + .metered(|| collab.write_card(&s.repo, &b, &target, &patch, true)) + .await?; + let fields: BTreeMap = + forge_core::rules::boards::parse_field_values(w.f.as_deref(), &spec) + .iter() + .filter_map(|(id, v)| spec.field(*id).map(|f| (f.name.clone(), value_text(f, v)))) + .collect(); + ctx.emit( + json!({ + "status": "set", + "board": b.key, + "fields": fields, + "card": card_json(&w, &label), + "cost": cost_json(spent, price), + }), + || println!("✓ {label} updated · {}", cost_line(spent, price)), + ); + Ok(()) +} + +/// The bulk card writes. +enum Bulk { + /// Put on the board (in this column). + Add(Option), + Archive, + Restore, + Remove, +} + +impl Bulk { + fn verb(&self) -> (&'static str, &'static str) { + match self { + Self::Add(_) => ("Add", "added"), + Self::Archive => ("Archive", "archived"), + Self::Restore => ("Restore", "restored"), + Self::Remove => ("Remove", "removed"), + } + } +} + +/// The landed part of a bulk write, and the E106 error when it stopped early. +fn bulk_outcome( + ctx: &Ctx, + done: &BulkWritten, + labels: &BTreeMap, + body: Value, + past: &str, +) -> Result<()> { + let print_landed = || { + for w in &done.written { + println!( + "✓ {} {past}", + labels.get(&w.item).map_or("item", String::as_str) + ); + } + }; + let Some((item, e)) = &done.failed else { + ctx.emit(body, print_landed); + return Ok(()); + }; + let label = labels.get(item).cloned().unwrap_or_else(|| item.clone()); + let error = forge_core::user_error::UserError::new( + forge_core::user_error::codes::PARTIAL, + format!( + "{} of {} {past}; {label} was not: {e}", + done.written.len(), + done.written.len() + 1 + done.skipped.len() + ), + ) + .note(format!("{} not tried", plural(done.skipped.len(), "item"))) + .fix("run the same command again: items already done are unchanged and cost nothing more"); + if !ctx.json { + print_landed(); + } + Err(crate::errors::reported(error, body)) +} + +/// The JSON of a bulk write. +pub(crate) fn bulk_json( + status: &str, + key: u32, + done: &BulkWritten, + labels: &BTreeMap, + cost: &Value, +) -> Value { + json!({ + "status": status, + "board": key, + "count": done.written.len(), + "cards": done.written.iter().map(|w| card_json(w, labels.get(&w.item).map_or("", String::as_str))).collect::>(), + "failed": done.failed.as_ref().map(|(item, e)| json!({ "item": item, "error": e.to_string() })), + "skipped": done.skipped, + "cost": cost, + }) +} + +async fn bulk(ctx: &Ctx, repo: &str, board: &str, items: &[String], op: Bulk) -> Result<()> { + let (s, b, spec) = open_board(ctx, repo, board, "board not changed").await?; + let collab = s.collab(); + let col = match &op { + Bulk::Add(Some(c)) => Some(find_column(&spec, c).ok_or_else(|| no_column(&spec, c))?), + _ => None, + }; + let snap = snapshot(&collab, &s.repo, &b).await?; + let mut targets: Vec = Vec::new(); + let mut labels = BTreeMap::new(); + for arg in items { + let (t, label) = find_item(&collab, &s, &snap, arg).await?; + if !targets.contains(&t) { + labels.insert(t.id.clone(), label); + targets.push(t); + } + } + let patch = match &op { + Bulk::Add(_) => CardPatch { + col, + state: Some(CARD_ACTIVE), + ..CardPatch::default() + }, + Bulk::Archive => CardPatch::state(CARD_ARCHIVED), + Bulk::Restore => CardPatch::state(CARD_ACTIVE), + Bulk::Remove => CardPatch::state(CARD_REMOVED), + }; + let writes: Vec<(CardItem, CardPatch)> = + targets.iter().map(|t| (t.clone(), patch.clone())).collect(); + let ids: Vec = targets.iter().map(|t| t.id.clone()).collect(); + let price = ctx.fiat_price(); + let quote = card_quote(&s, &snap, &ids); + let (verb, past) = op.verb(); + let names: Vec = targets.iter().map(|t| labels[&t.id].clone()).collect(); + ctx.confirm_or_cancel(&format!( + "{verb} {} on board {:?}? ({}, {} estimated{}", + crate::fmt::join_and(&names), + board_name(&b), + plural(writes.len(), "document"), + cost_line(quote, price), + cross_repo_suffix(&s.repo, &targets) + ))?; + let before = s.balance().await; + let done = collab.write_cards(&s.repo, &b, &writes, true).await; + let spent = s.spent_since(before).await; + let body = bulk_json(past, b.key, &done, &labels, &cost_json(spent, price)); + bulk_outcome(ctx, &done, &labels, body, past) +} + +async fn quick_add( + ctx: &Ctx, + repo: &str, + board: &str, + title: &str, + column: Option<&str>, +) -> Result<()> { + let (s, b, spec) = open_board(ctx, repo, board, "issue not created").await?; + s.refuse_if_banned("issue not created").await?; + let collab = s.collab(); + let col = match column { + Some(c) => find_column(&spec, c).ok_or_else(|| no_column(&spec, c))?, + None => spec.def, + }; + let snap = snapshot(&collab, &s.repo, &b).await?; + let price = ctx.fiat_price(); + let quote = crate::quote::target_create(title.len() as u64) + + crate::quote::card_create(card_bytes(&s.repo)); + ctx.confirm_or_cancel(&format!( + "Open issue {title:?} in {} and put it in {:?} on board {:?}? (two documents, {} estimated)", + s.repo.display(), + column_name(&spec, col), + board_name(&b), + cost_line(quote, price) + ))?; + let journal = forge_core::create::default_journal_dir()?; + let column_cards = snap.column(col); + let before = s.balance().await; + let added = collab + .quick_add_issue(&s.repo, &b, title, col, &column_cards, None, &journal, true) + .await?; + let spent = s.spent_since(before).await; + let label = format!("#{}", added.item.number); + match &added.card { + Ok(w) => { + ctx.emit( + json!({ + "status": "added", + "board": b.key, + "issue": { "number": added.item.number, "id": added.item.id }, + "column": column_name(&spec, col), + "card": card_json(w, &label), + "cost": cost_json(spent, price), + }), + || { + println!( + "✓ issue {label} opened and put in {} · {}", + column_name(&spec, col), + cost_line(spent, price) + ); + }, + ); + Ok(()) + } + Err(e) => { + let error = forge_core::user_error::UserError::new( + forge_core::user_error::codes::PARTIAL, + format!("issue {label} was opened, but not put on the board: {e}"), + ) + .fix(format!("`dg board add {repo} {} {label}`", b.key)); + Err(crate::errors::reported( + error, + json!({ + "status": "created", + "board": b.key, + "issue": { "number": added.item.number, "id": added.item.id }, + "cost": cost_json(spent, price), + }), + )) + } + } +} + +async fn next_iteration(ctx: &Ctx, repo: &str, board: &str, field: Option<&str>) -> Result<()> { + let (s, b, spec) = open_board(ctx, repo, board, "board not changed").await?; + let collab = s.collab(); + let iter = match field { + Some(name) => find_field(&spec, name) + .filter(|f| f.kind == FieldType::Iter) + .ok_or_else(|| { + crate::errors::usage(format!("this board has no iteration field {name:?}")) + })?, + None => spec + .fields + .iter() + .find(|f| f.kind == FieldType::Iter) + .ok_or_else(|| crate::errors::usage("this board has no iteration field"))?, + }; + let snap = snapshot(&collab, &s.repo, &b).await?; + // the board read again: its definition may not open now (another member sealed or broke it) + spec_of(&snap.read.board)?; + let placements: Vec = snap + .fold + .as_ref() + .map(|f| f.items.clone()) + .unwrap_or_default(); + let Some((next, moving)) = forge_core::collab::boards::next_iteration_plan( + &spec, + iter.id, + &snap.items.items, + &placements, + snap.now, + ) else { + return Err(crate::errors::usage(format!( + "{} has no current iteration to move items from (its first starts {})", + iter.name, + iter.start.as_deref().unwrap_or("later") + ))); + }; + let next_name = iteration_range(iter, next) + .map_or_else(|| format!("{} {}", iter.name, next + 1), |r| r.name); + let labels: BTreeMap = moving + .iter() + .filter_map(|m| { + snap.item(&m.id) + .map(|i| (m.id.clone(), item_label(i, s.repo.id()))) + }) + .collect(); + if moving.is_empty() { + ctx.emit( + json!({ "status": "moved", "board": b.key, "iteration": next_name, "count": 0, "cards": [], "failed": null, "skipped": [], "cost": cost_json(0, ctx.fiat_price()) }), + || println!("nothing to move: every item of the current iteration is done"), + ); + return Ok(()); + } + let ids: Vec = moving.iter().map(|m| m.id.clone()).collect(); + let price = ctx.fiat_price(); + let quote = card_quote(&s, &snap, &ids); + let names: Vec = ids + .iter() + .map(|id| labels.get(id).cloned().unwrap_or_default()) + .collect(); + ctx.confirm_or_cancel(&format!( + "Move {} into {next_name}? ({}, {} estimated)", + crate::fmt::join_and(&names), + plural(ids.len(), "document"), + cost_line(quote, price) + ))?; + let before = s.balance().await; + let done = collab + .move_open_to_next_iteration(&s.repo, &snap, iter.id) + .await?; + let spent = s.spent_since(before).await; + let mut body = bulk_json("moved", b.key, &done, &labels, &cost_json(spent, price)); + body["iteration"] = json!(next_name); + bulk_outcome( + ctx, + &done, + &labels, + body, + &format!("moved into {next_name}"), + ) +} + +#[cfg(test)] +mod tests; diff --git a/crates/dg/src/board/tests.rs b/crates/dg/src/board/tests.rs new file mode 100644 index 000000000..6c7fe830b --- /dev/null +++ b/crates/dg/src/board/tests.rs @@ -0,0 +1,240 @@ +//! `dg board`'s argument parsing and the definitions it creates, offline. + +use clap::Parser as _; + +use super::*; +use crate::Cli; + +const HOME: &str = "4X5xgudNAwLhWEL3jgsisYszZXPnf33VbyaAqjbUB9Yi"; + +#[test] +fn an_item_is_a_number_a_repo_and_number_or_a_kind_and_number() { + let a = |s: &str| parse_item_arg(s).unwrap(); + let item = |kind, repo: Option<&str>, number| ItemArg { + kind, + repo: repo.map(str::to_string), + number, + }; + assert_eq!(a("#12"), item(None, None, 12)); + assert_eq!(a("12"), item(None, None, 12)); + assert_eq!(a("pr#7"), item(Some(ItemKind::Pr), None, 7)); + assert_eq!(a("PR#7"), item(Some(ItemKind::Pr), None, 7)); + assert_eq!(a("issue#3"), item(Some(ItemKind::Issue), None, 3)); + assert_eq!(a("alice/proj#4"), item(None, Some("alice/proj"), 4)); + assert_eq!( + a("https://forge.dashhq.org/repo/pull/?owner=alice&name=proj&number=9"), + item(None, Some("alice/proj"), 9) + ); + for bad in ["", "#", "pr#", "twelve", "#-1", "alice/proj", "#1.5"] { + assert!(parse_item_arg(bad).is_err(), "{bad:?}"); + } +} + +#[test] +fn a_new_board_starts_from_its_template_with_the_columns_given() { + let spec = spec_for(BoardTemplate::Kanban, HOME, None, 0).unwrap(); + assert_eq!(spec, default_spec(HOME, 0)); + let spec = spec_for( + BoardTemplate::Kanban, + HOME, + Some(" Backlog, Doing ,Review,done "), + 0, + ) + .unwrap(); + let names: Vec<&str> = spec.columns.iter().map(|c| c.name.as_str()).collect(); + assert_eq!(names, ["Backlog", "Doing", "Review", "done"]); + assert_eq!((spec.def, spec.done), (1, 4)); + // the definition is one the rules accept, sources and views included + assert!(forge_core::collab::boards::check_board_input("Sprint", &spec).is_ok()); + let empty = spec_for(BoardTemplate::Empty, HOME, Some("A,B"), 0).unwrap(); + assert!(empty.sources.is_empty() && empty.fields.is_empty()); + assert!(empty.views.is_empty()); + assert_eq!((empty.done, empty.arch), (0, 0)); + assert!(forge_core::collab::boards::check_board_input("Ideas", &empty).is_ok()); + // every template is a definition the board rules accept, as the web's create dialog writes it + for t in [ + BoardTemplate::Kanban, + BoardTemplate::Sprint, + BoardTemplate::Triage, + BoardTemplate::Empty, + ] { + let spec = spec_for(t, HOME, None, 1_800_000_000_000).unwrap(); + assert!( + forge_core::collab::boards::check_board_input("Board", &spec).is_ok(), + "{t:?}" + ); + } + let triage = spec_for(BoardTemplate::Triage, HOME, None, 0).unwrap(); + assert_eq!(triage.sources[0].q, "label:bug"); + assert_eq!((triage.def, triage.done), (1, 4)); + assert!(spec_for(BoardTemplate::Kanban, HOME, Some("A,,B"), 0).is_err()); + let many = vec!["c"; 21].join(","); + assert!(spec_for(BoardTemplate::Kanban, HOME, Some(&many), 0).is_err()); +} + +#[test] +fn columns_and_fields_are_found_by_name_in_any_case() { + let spec = default_spec(HOME, 0); + assert_eq!(find_column(&spec, "in PROGRESS"), Some(2)); + assert_eq!(find_column(&spec, "3"), Some(3)); + // "No status" is a column only on a board whose default is none (def 0): elsewhere an item + // without a column shows in the default column, so a move there is refused + assert_eq!(find_column(&spec, "none"), None); + let mut no_default = spec.clone(); + no_default.def = 0; + assert_eq!(find_column(&no_default, "No Status"), Some(0)); + assert_eq!(find_column(&spec, "Later"), None); + assert_eq!(find_field(&spec, "priority").map(|f| f.id), Some(1)); + assert_eq!(column_name(&spec, 0), "No status"); +} + +#[test] +fn field_values_are_typed_by_their_field() { + let spec = default_spec(HOME, 0); // Iteration from 1969-12-29, 14 days + let now = 20 * 86_400_000; // in its second iteration (index 1) + let field = |name: &str| find_field(&spec, name).unwrap(); + let v = |name: &str, raw: &str| parse_value(field(name), raw, now); + assert_eq!(v("Priority", "p1").unwrap(), Some(Scalar::from(2))); + assert!(v("Priority", "P9").is_err()); + assert_eq!(v("Estimate", "2.5").unwrap(), Some(Scalar::Num(2.5))); + assert!(v("Estimate", "lots").is_err()); + assert_eq!(v("Iteration", "@current").unwrap(), Some(Scalar::from(1))); + assert_eq!(v("Iteration", "@next").unwrap(), Some(Scalar::from(2))); + assert_eq!(v("Iteration", "@previous").unwrap(), Some(Scalar::from(0))); + assert_eq!( + v("Iteration", "Iteration 4").unwrap(), + Some(Scalar::from(3)) + ); + assert_eq!(v("Iteration", "4").unwrap(), Some(Scalar::from(3))); + assert!(v("Iteration", "0").is_err()); + assert_eq!(v("Estimate", " ").unwrap(), None, "an empty value clears"); + assert_eq!(value_text(field("Priority"), &Scalar::from(2)), "P1"); + assert_eq!( + value_text(field("Iteration"), &Scalar::from(3)), + "Iteration 4" + ); + assert_eq!(value_text(field("Estimate"), &Scalar::Num(3.0)), "3"); +} + +#[test] +fn assignments_make_one_patch() { + let spec = default_spec(HOME, 0); + let patch = parse_assignments( + &spec, + &[ + "priority=P0".into(), + "Estimate=".into(), + "status=Done".into(), + ], + 0, + ) + .unwrap(); + assert_eq!(patch.col, Some(3)); + assert_eq!(patch.fields.get(&1), Some(&Some(Scalar::from(1)))); + assert_eq!(patch.fields.get(&2), Some(&None)); + assert!(parse_assignments(&spec, &["priority".into()], 0).is_err()); + assert!(parse_assignments(&spec, &["colour=red".into()], 0).is_err()); + assert!(parse_assignments(&spec, &["status=Later".into()], 0).is_err()); +} + +fn parse(args: &[&str]) -> Result { + Cli::try_parse_from(std::iter::once("dg").chain(args.iter().copied())) +} + +#[test] +fn the_board_commands_parse_as_documented() { + let cli = parse(&[ + "board", + "move", + "alice/proj", + "7", + "#12", + "Done", + "--before", + "#3", + ]) + .unwrap(); + let crate::Command::Board(BoardCommand::Move { + item, + column, + before, + top, + .. + }) = cli.command + else { + panic!("not a move"); + }; + assert_eq!( + (item.as_str(), column.as_str(), before.as_deref(), top), + ("#12", "Done", Some("#3"), false) + ); + assert!(parse(&["board", "move", "a/p", "7", "#1", "Done", "--top", "--bottom"]).is_err()); + assert!( + parse(&["board", "move", "a/p", "7", "#1", "Done", "--before", "#2", "--after", "#3"]) + .is_err() + ); + assert!( + parse(&["board", "set", "a/p", "7", "#1"]).is_err(), + "set needs a value" + ); + assert!(parse(&[ + "board", + "set", + "a/p", + "7", + "#1", + "priority=P1", + "estimate=3" + ]) + .is_ok()); + assert!( + parse(&["board", "add", "a/p", "7"]).is_err(), + "add needs items or --title" + ); + assert!(parse(&["board", "add", "a/p", "7", "--title", "Fix it"]).is_ok()); + assert!(parse(&["board", "add", "a/p", "7", "#1", "--title", "Fix it"]).is_err()); + assert!(parse(&["board", "add", "a/p", "7", "#1", "a/q#2", "--column", "Todo"]).is_ok()); + assert!(parse(&["board", "archive", "a/p", "7", "#1", "--restore"]).is_ok()); + assert!(parse(&["board", "remove", "a/p", "7"]).is_err()); + assert!(parse(&[ + "board", + "create", + "a/p", + "--name", + "Sprint", + "--columns", + "A,B", + "--template", + "empty" + ]) + .is_ok()); + assert!(parse(&[ + "board", + "create", + "a/p", + "--name", + "Sprint", + "--template", + "kanban-ish" + ]) + .is_err()); + for t in ["kanban", "sprint", "triage", "bugs", "empty"] { + assert!( + parse(&["board", "create", "a/p", "--name", "S", "--template", t]).is_ok(), + "{t}" + ); + } + assert!(parse(&[ + "board", + "view", + "a/p", + "Roadmap", + "--view", + "Table", + "--archived" + ]) + .is_ok()); + assert!(parse(&["board", "next-iteration", "a/p", "7", "--field", "Sprint"]).is_ok()); + assert!(parse(&["board", "close", "a/p", "7", "--reopen"]).is_ok()); + assert!(parse(&["board", "list", "a/p", "--deleted"]).is_ok()); +} diff --git a/crates/dg/src/errors.rs b/crates/dg/src/errors.rs index 89b5b33ae..ba56a74b4 100644 --- a/crates/dg/src/errors.rs +++ b/crates/dg/src/errors.rs @@ -15,8 +15,8 @@ use forge_core::user_error::{self, codes, ErrorContext, UserError}; use serde_json::Value; use crate::{ - CollabCommand, Command, CostCommand, IssueCommand, LabelCommand, MilestoneCommand, PrCommand, - ReleaseCommand, RepoBackendCommand, RepoCommand, StorageCommand, + BoardCommand, CollabCommand, Command, CostCommand, IssueCommand, LabelCommand, + MilestoneCommand, PrCommand, ReleaseCommand, RepoBackendCommand, RepoCommand, StorageCommand, }; /// A failure with a result of its own: `body` is the command's `--json` object (printed @@ -202,6 +202,21 @@ pub fn context_for(cmd: &Command) -> (Option<&'static str>, Option<&str>) { | Command::Milestone( MilestoneCommand::Create { repo, .. } | MilestoneCommand::Close { repo, .. }, ) => ("milestone not changed", Some(repo)), + Command::Board(BoardCommand::List { repo, .. } | BoardCommand::View { repo, .. }) => { + ("could not read the boards", Some(repo)) + } + Command::Board(BoardCommand::Create { repo, .. }) => ("board not created", Some(repo)), + Command::Board(BoardCommand::Close { repo, .. } | BoardCommand::Delete { repo, .. }) => { + ("board not changed", Some(repo)) + } + Command::Board( + BoardCommand::Move { repo, .. } + | BoardCommand::Set { repo, .. } + | BoardCommand::Add { repo, .. } + | BoardCommand::Archive { repo, .. } + | BoardCommand::Remove { repo, .. } + | BoardCommand::NextIteration { repo, .. }, + ) => ("board not changed", Some(repo)), Command::Issue(I::Reopen { repo, .. }) => ("issue not reopened", Some(repo)), Command::Issue(I::Edit { repo, .. }) => ("issue not edited", Some(repo)), Command::Issue(I::EditComment { repo, .. }) => ("comment not edited", Some(repo)), diff --git a/crates/dg/src/json_schemas.rs b/crates/dg/src/json_schemas.rs index 97c45b875..76707af0e 100644 --- a/crates/dg/src/json_schemas.rs +++ b/crates/dg/src/json_schemas.rs @@ -559,3 +559,131 @@ fn ipfs_pin_reports_match() { ), ); } + +/// `dg board`'s builders: a board with a carded and a sourced item, viewed as the board and as +/// a saved view, a list, a card write and a bulk write that stopped early. +#[test] +#[allow(clippy::too_many_lines)] // one board, built up, then each output +fn board_outputs_match_their_schemas() { + use forge_core::collab::boards::{ + Board, BoardItemSet, BoardRead, BoardRevision, BoardSnapshot, BoardState, BulkWritten, + CardWritten, + }; + use forge_core::rules::boards::{ + default_spec, fold_board, BoardItem, CardDoc, ItemKind, ItemState, + }; + let home = "4X5xgudNAwLhWEL3jgsisYszZXPnf33VbyaAqjbUB9Yi"; + let spec = default_spec(home, 0); + let item = |id: &str, kind, state| BoardItem { + id: id.into(), + number: 3, + repo_id: home.into(), + repo: Some(format!("{home}/proj")), + kind, + state, + created_at: 5, + closed_at: (state != ItemState::Open).then_some(9), + title: "Fix it".into(), + labels: vec!["bug".into()], + assignees: Vec::new(), + milestone: None, + author: home.into(), + }; + let items = vec![ + item("a", ItemKind::Issue, ItemState::Open), + item("b", ItemKind::Pr, ItemState::Merged), + ]; + let cards = vec![CardDoc { + id: "c".into(), + owner_id: home.into(), + updated_at: 10, + item: "a".into(), + col: Some(2), + rank: Some("1".into()), + f: Some(r#"{"1":2,"2":3,"3":0}"#.into()), + state: 0, + }]; + let now = 86_400_000; + let board = Board { + key: 7, + repo_id: home.into(), + state: BoardState::Open, + name: Some("Roadmap".into()), + spec: Some(spec.clone()), + spec_error: None, + sealed: false, + newest: BoardRevision { + id: "r".into(), + owner_id: home.into(), + updated_at: 1, + }, + revisions: Vec::new(), + }; + let snap = BoardSnapshot { + read: BoardRead { + board: board.clone(), + cards: Vec::new(), + since: 10, + }, + fold: Some(fold_board(&spec, home, &items, &cards, now)), + items: BoardItemSet { + items, + ..BoardItemSet::default() + }, + now, + }; + for view in [None, spec.views.get(1)] { + let shown = crate::board::shown( + &snap, + &spec, + view, + false, + Some(home), + &std::collections::HashMap::new(), + ); + let body = crate::board::view_json(&snap, &shown); + assert_valid("board view", &body); + assert_eq!(body["columns"].as_array().map(Vec::len), Some(3)); + } + let mut sealed = board.clone(); + (sealed.name, sealed.spec, sealed.spec_error) = (None, None, Some("unreadable".into())); + assert_valid("board list", &crate::board::list_json(&[board, sealed])); + let w = CardWritten { + item: "a".into(), + document_id: "d".into(), + created: true, + changed: true, + col: Some(2), + rank: Some("1".into()), + f: None, + state: 1, + }; + let price = crate::fmt::Price::new(false); + assert_valid( + "board move", + &json!({"status":"moved","board":7,"column":"Done","card":crate::board::card_json(&w, "#3"), + "cost":crate::fmt::cost_json(1, price)}), + ); + let done = BulkWritten { + written: vec![w], + failed: Some(("b".into(), forge_core::error::Error::NotFound)), + skipped: vec!["e".into()], + }; + let labels = [("a".to_string(), "#3".to_string())].into(); + let body = crate::board::bulk_json( + "archived", + 7, + &done, + &labels, + &crate::fmt::cost_json(1, price), + ); + assert_valid("board archive", &body); + assert_valid("board remove", &body); + assert_error_valid( + &body, + &forge_core::user_error::UserError::new( + forge_core::user_error::codes::PARTIAL, + "1 of 3 archived", + ), + ); +} diff --git a/crates/dg/src/main.rs b/crates/dg/src/main.rs index 0876e8427..e9273a3b4 100644 --- a/crates/dg/src/main.rs +++ b/crates/dg/src/main.rs @@ -10,6 +10,7 @@ mod attestation_signer; mod audience; mod auth; mod bans; +mod board; mod bot; mod bot_push; mod branch; @@ -203,6 +204,9 @@ pub enum Command { /// Milestones (put an issue in one with `dg issue milestone`). #[command(subcommand)] Milestone(MilestoneCommand), + /// Boards: issues and pull requests in columns, with fields, iterations and saved views. + #[command(subcommand)] + Board(BoardCommand), /// Your public profile: display name, bio, avatar, links, location, company, signing keys. #[command(subcommand)] Profile(ProfileCommand), @@ -1259,6 +1263,172 @@ pub enum MilestoneCommand { }, } +/// A new board's starting definition (`dg board create --template`): the web's create-dialog +/// templates (forge-web `components/repo/boards/board-templates.ts`). +#[derive(Debug, Clone, Copy, PartialEq, Eq, clap::ValueEnum)] +pub enum BoardTemplate { + /// Todo, In progress and Done; every issue and pull request of the repository; Priority, + /// Estimate and a two-week Iteration; done items archived after 14 days. + Kanban, + /// Backlog, Todo, In progress, In review and Done, with two-week sprints, estimates and a + /// "Current sprint" view. + Sprint, + /// Needs triage, Confirmed, In progress and Fixed, holding every issue labelled bug, with a + /// Priority. + #[value(alias = "bugs")] + Triage, + /// One column and nothing added for you: only the items you put on it. + Empty, +} + +#[derive(Debug, Subcommand)] +pub enum BoardCommand { + /// List a repository's boards, open and closed. + List { + /// The repository (`owner/name`). + repo: String, + /// Include deleted boards. + #[arg(long)] + deleted: bool, + }, + /// Show a board: each column with its items, their fields, the column's totals and its + /// work-in-progress limit. + View { + /// The repository (`owner/name`). + repo: String, + /// The board: its number (as `dg board list` shows it) or its name. + board: String, + /// Show it as one of its saved views shows it (its filter, sort and totals). + #[arg(long = "view", value_name = "NAME")] + view: Option, + /// Also show archived items. + #[arg(long)] + archived: bool, + }, + /// Create a board. Maintainers and writers. + Create { + /// The repository (`owner/name`). + repo: String, + /// The board's name. + #[arg(long)] + name: String, + /// The columns, in order, comma-separated (default `Todo,In progress,Done`). A column + /// named Done takes closed and merged items. + #[arg(long, value_name = "A,B,C")] + columns: Option, + /// What the board starts with. + #[arg(long, value_enum, default_value = "kanban")] + template: BoardTemplate, + }, + /// Move an item to a column: to its bottom, or with `--top`, `--before` or `--after`. + /// Maintainers, writers and triage members. + Move { + /// The repository (`owner/name`). + repo: String, + /// The board: its number or its name. + board: String, + /// The item: `#12`, `12`, `owner/name#12`, or `pr#12` when an issue and a pull request share the number. + item: String, + /// The column, by name. + column: String, + /// At the top of the column. + #[arg(long, conflicts_with_all = ["bottom", "before", "after"])] + top: bool, + /// At the bottom of the column (the default). + #[arg(long, conflicts_with_all = ["before", "after"])] + bottom: bool, + /// Just above this item of the column. + #[arg(long, value_name = "ITEM", conflicts_with = "after")] + before: Option, + /// Just below this item of the column. + #[arg(long, value_name = "ITEM")] + after: Option, + }, + /// Set an item's fields, `priority=P1 estimate=3 iteration=@next` (an empty value clears + /// one; `status=` moves it). Maintainers, writers and triage members. + Set { + /// The repository (`owner/name`). + repo: String, + /// The board: its number or its name. + board: String, + /// The item: `#12`, `12`, `owner/name#12` or `pr#12`. + item: String, + /// `field=value` pairs, field names as the board names them. + #[arg(required = true, num_args = 1.., value_name = "FIELD=VALUE")] + values: Vec, + }, + /// Put items on a board, or open a new issue there with `--title`. Maintainers, writers + /// and triage members. + Add { + /// The repository (`owner/name`). + repo: String, + /// The board: its number or its name. + board: String, + /// The items: `#12`, `12`, `owner/name#12` or `pr#12`. + #[arg(required_unless_present = "title", value_name = "ITEM")] + items: Vec, + /// The column to put them in (default: the board's default column). + #[arg(long)] + column: Option, + /// Open a new issue with this title in the repository and put it on the board. + #[arg(long, conflicts_with = "items")] + title: Option, + }, + /// Archive items: hidden from the board unless a view asks for archived ones. + /// Maintainers, writers and triage members. + Archive { + /// The repository (`owner/name`). + repo: String, + /// The board: its number or its name. + board: String, + /// The items: `#12`, `12`, `owner/name#12` or `pr#12`. + #[arg(required = true, value_name = "ITEM")] + items: Vec, + /// Bring archived items back instead. + #[arg(long)] + restore: bool, + }, + /// Remove items from a board, even ones it would include by itself. Maintainers, writers + /// and triage members. + Remove { + /// The repository (`owner/name`). + repo: String, + /// The board: its number or its name. + board: String, + /// The items: `#12`, `12`, `owner/name#12` or `pr#12`. + #[arg(required = true, value_name = "ITEM")] + items: Vec, + }, + /// Move every open item of the current iteration that is not done into the next iteration. + NextIteration { + /// The repository (`owner/name`). + repo: String, + /// The board: its number or its name. + board: String, + /// The iteration field, by name (default: the board's first). + #[arg(long)] + field: Option, + }, + /// Close a board (read-only, listed under closed), or reopen it with `--reopen`. + /// Maintainers and writers. + Close { + /// The repository (`owner/name`). + repo: String, + /// The board: its number or its name. + board: String, + /// Reopen instead. + #[arg(long)] + reopen: bool, + }, + /// Delete a board. Maintainers and writers. + Delete { + /// The repository (`owner/name`). + repo: String, + /// The board: its number or its name. + board: String, + }, +} + /// `dg issue list` arguments. #[derive(Debug, clap::Args)] pub struct IssueListArgs { @@ -2673,6 +2843,7 @@ async fn dispatch(ctx: &Ctx, cli: &Cli) -> Result<()> { Command::Release(cmd) => Box::pin(release::run(ctx, cmd)).await, Command::Label(cmd) => label::run(ctx, cmd).await, Command::Milestone(cmd) => milestone::run(ctx, cmd).await, + Command::Board(cmd) => Box::pin(board::run(ctx, cmd)).await, Command::Profile(cmd) => profile::run(ctx, cmd).await, Command::VerifyCommit { repo, revs, author } => { signing::verify_commits(ctx, repo.as_deref(), revs, author).await diff --git a/crates/dg/src/quote.rs b/crates/dg/src/quote.rs index 90d089a5c..14c4f4077 100644 --- a/crates/dg/src/quote.rs +++ b/crates/dg/src/quote.rs @@ -104,6 +104,43 @@ pub fn milestone_definition(text_bytes: u64) -> u64 { collab_doc_credits(CollabDoc::Label, DEFINITION_FIXED_BYTES + text_bytes) + 10_000_000 } +/// What a `board` or `card` (UPDATE-3, `docs/design/boards.md` §7) stores per byte of text, +/// as every write: forge-web's `CREDITS_PER_TEXT_BYTE`. +const BOARD_CREDITS_PER_BYTE: u64 = 27_500; + +/// A member's first revision of a board carrying `text_bytes` of name and definition (sealed: +/// its `enc`), priced as the repository's first and the signer's first forge-meta write: forge-web's +/// `BASE_CREDITS.board` (34M), its first-board surcharge (10M) and the contract nonce (12M), with +/// headroom (1.06), and the bytes. Measured on testnet (2026-10-27, +/// `boards.live.test.ts`): 62.8M-63.8M for a repository's first with 738 bytes, 53.7M-54.7M later. +pub fn board_create(text_bytes: u64) -> u64 { + 60_000_000 + BOARD_CREDITS_PER_BYTE * text_bytes +} + +/// A replace of the signer's own board revision or card carrying `text_bytes`: forge-web's +/// `REPLACE_BASE_BY_TYPE` (4.7M a board, 5.15M a card), rounded up. Measured on a testnet scratch +/// set: a board's rename, close or delete 3.4M-4.6M, a card's move, field change or archive 4.2M-5.2M. +pub fn board_replace(text_bytes: u64) -> u64 { + 5_200_000 + BOARD_CREDITS_PER_BYTE * text_bytes +} + +/// A member's first card for an item carrying `text_bytes` of column, rank and fields, priced as +/// a board's first card and the signer's first forge-meta write: forge-web's `BASE_CREDITS.card` +/// (43M) with the board's first card (18.5M), the item's first (28.5M) and the contract nonce (12M) +/// surcharges, with headroom (1.06). Measured on testnet: 88.3M-89.1M a board's first +/// card, 70.5M-70.9M an item's first, 42.8M-43.2M for an item another member has a card for. +pub fn card_create(text_bytes: u64) -> u64 { + 109_000_000 + BOARD_CREDITS_PER_BYTE * text_bytes +} + +/// `creates` first cards and `replaces` card replaces of about `text_bytes` each (a re-rank, a +/// bulk archive, "move to the next iteration"): the web's `priceBoardWrites`. +pub fn card_writes(creates: usize, replaces: usize, text_bytes: u64) -> u64 { + let n = |k: usize| u64::try_from(k).unwrap_or(u64::MAX); + n(creates).saturating_mul(card_create(text_bytes)) + + n(replaces).saturating_mul(board_replace(text_bytes)) +} + /// A `topic` document, priced as the repository's first: 61.7M-62.6M on bonsia (QA wave 3), /// the repository's first 72.9M. pub const TOPIC: u64 = 78_000_000; diff --git a/crates/dg/tests/snapshots/dg-help.txt b/crates/dg/tests/snapshots/dg-help.txt index db5f85561..118052721 100644 --- a/crates/dg/tests/snapshots/dg-help.txt +++ b/crates/dg/tests/snapshots/dg-help.txt @@ -10,6 +10,7 @@ Commands: release Releases label Label definitions (apply one with `dg issue label`) milestone Milestones (put an issue in one with `dg issue milestone`) + board Boards: issues and pull requests in columns, with fields, iterations and saved views profile Your public profile: display name, bio, avatar, links, location, company, signing keys verify-commit Check commits' signatures against the keys a repository's owner and members publish on their profiles: the web's Verified / Unverified badges, for a clone's commits verify-mirror Check a plain-git mirror of a repository (a gateway's https clone URL) against Dash Platform: each ref it serves is a match, stale (behind) or a MISMATCH diff --git a/crates/forge-core/Cargo.toml b/crates/forge-core/Cargo.toml index e81377d7e..74da5ea9f 100644 --- a/crates/forge-core/Cargo.toml +++ b/crates/forge-core/Cargo.toml @@ -11,7 +11,9 @@ description = "Shared library for Dash Forge: platform client, pack pipeline, ba [dependencies] thiserror.workspace = true serde.workspace = true -serde_json.workspace = true +# `float_roundtrip`: read every JSON number exactly, as JavaScript's `JSON.parse` does (the default +# parser is off by one ulp for some; a board card's number field must read alike in both clients). +serde_json = { workspace = true, features = ["float_roundtrip"] } tracing.workspace = true # The CLIs' shared stderr logger (`logging`, feature `cli-logging`), which hides the SDK's # recovered-error noise. diff --git a/crates/forge-core/src/collab/boards.rs b/crates/forge-core/src/collab/boards.rs new file mode 100644 index 000000000..20c757fa1 --- /dev/null +++ b/crates/forge-core/src/collab/boards.rs @@ -0,0 +1,2479 @@ +//! Boards (`docs/design/boards.md`; forge-meta `board` and `card`, UPDATE-3): reading a +//! repository's boards and cards, assembling the items a board folds, and every board and card +//! write. A fifth `impl` of [`super::v2::Collab`]; the pure rules are +//! [`crate::rules::boards`]. Parity: forge-web `lib/repo/boards.ts` (reads), +//! `lib/repo/board-items.ts` (items) and `lib/repo/board-writes.ts` (writes). +//! +//! * **Reads**: [`Collab::boards`] (a repo's boards, newest revision per key over every +//! member's, deleted dropped), [`Collab::board`] (one board's definition and every card, the +//! `card.recent` index), [`Collab::cards_since`] (`$updatedAt >=` a time, merged by `$id` with +//! [`merge_cards`]), [`Collab::item_card_docs`] (`card.onItem`: one item's cards on one board, +//! and the signer's own document) and [`Collab::item_boards`] (an item's boards whose home is +//! its repository or another of the same owner, §5.6). +//! * **Items** ([`Collab::board_items`], §2.3, §2.4): per source repository its open issues and +//! pull requests, the closed ones inside the auto-archive window (or, with `arch` 0, the +//! [`CLOSED_PER_REPO`] most recently closed) and every closed one a card names; then every item +//! a card names outside the sources, by id, in any repository. The CLI reads the issue and PR +//! lists whole (the PRs page after page, up to [`PR_PAGES`]), so it filters in memory what +//! the web's feed walk pages through ([`select_source_items`]). +//! * **Writes**: one document operation each, the signer's role checked first (a board claims +//! `r` 1, writers and maintainers; a card 1 or 2, triage too: [`super::v2::gated_write`]), and +//! refused before signing where the contract or the board rules would refuse it. A board and a +//! card are one mutable document per member, so a write replaces the signer's own document +//! when they have one and creates it otherwise; a card is written over a fresh read of the +//! item's newest card, its change applied to it (§3.2, [`patched_card`]). +//! +//! A private repository's boards and cards are sealed ([`crate::private::board`], +//! private-repos.md §4.6): a member opens them with the repository's keys; a document carrying +//! plaintext content beside `enc`, a private one without `enc`, or one whose seal is malformed +//! is skipped by every reader, and a write still finds the signer's own document among the raw +//! rows. In a repository made public (§18) the sealed boards and cards of its private era open +//! with the epoch keys its owner published; any other public repository's sealed one (a later +//! client's members-only board) reads as unreadable, never dropped. + +use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; +use std::path::Path; +use std::sync::Arc; + +use serde::Serialize; + +use super::v2::{ + issue_from_doc, patch_from_doc, Collab, IssueView, PatchView, DOC_ISSUE, DOC_PATCH, +}; +use crate::error::{Error, Result}; +use crate::keyring::Keyring; +use crate::members; +use crate::platform::{self, FetchedDocument, FieldValue, LoadedContract, QueryFilter, QueryOrder}; +use crate::private::board::{self as sealed, Bind, BoardFields, CardFields, Content, Opened}; +use crate::rules::boards::{ + bottom_rank, field_value_ok, is_board_name, is_explicit_rank, iteration_at, newest_boards, + newest_cards, parse_field_values, parse_spec, rank_between, serialize_field_values, + serialize_spec, top_rank, BoardDoc, BoardFold, BoardItem, BoardSpec, CardDoc, FieldType, + ItemKind, ItemState, Placement, RankError, Scalar, SpecError, BOARD_DELETED, CARD_ACTIVE, + CARD_ARCHIVED, CARD_REMOVED, ITER_INDEX_MAX, +}; +use crate::rules::transition::{ISSUE_CLOSE, PR_CLOSE, PR_DRAFT_CLOSE, PR_MERGE}; +use crate::rules::v2::{fold_thread_meta_v2, Role, Visibility}; +use crate::scope::RepoRef; +use crate::user_error::{codes, UserError}; + +/// forge-meta (UPDATE-3, four-contract sets only): a member's revision of a board's definition. +pub const DOC_BOARD: &str = "board"; +/// forge-meta (UPDATE-3): a member's placement of one issue or PR on a board. +pub const DOC_CARD: &str = "card"; + +/// Board `state`: open. +pub const BOARD_OPEN: i64 = 0; +/// Board `state`: closed (read-only, listed under Closed). +pub const BOARD_CLOSED: i64 = 1; + +/// With auto-archive off, a source repository's closed items read at first are its most +/// recently closed this many (§2.4; the web's `CLOSED_PER_REPO`). +pub const CLOSED_PER_REPO: usize = 200; + +const DAY_MS: i64 = 86_400_000; + +/// A board's state (§3.1 `state`). +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)] +#[serde(rename_all = "lowercase")] +pub enum BoardState { + /// Open. + Open, + /// Closed: read-only, listed under Closed. + Closed, + /// Deleted (state 2 is the delete: the documents are never deleted). + Deleted, +} + +impl BoardState { + /// The `board.state` integer. + #[must_use] + pub fn code(self) -> i64 { + match self { + Self::Open => BOARD_OPEN, + Self::Closed => BOARD_CLOSED, + Self::Deleted => BOARD_DELETED, + } + } + + fn of(code: i64) -> Self { + match code { + BOARD_CLOSED => Self::Closed, + BOARD_DELETED => Self::Deleted, + _ => Self::Open, + } + } + + /// `open`, `closed` or `deleted`. + #[must_use] + pub fn as_str(self) -> &'static str { + match self { + Self::Open => "open", + Self::Closed => "closed", + Self::Deleted => "deleted", + } + } +} + +/// One member's revision of a board: one document per (home repo, key, member), replaced in +/// place. +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct BoardRevision { + /// `$id`. + pub id: String, + /// `$ownerId`. + pub owner_id: String, + /// `$updatedAt`. + pub updated_at: i64, +} + +/// A board as its newest revision defines it (the web's `BoardView`). +#[derive(Debug, Clone, PartialEq, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct Board { + /// The board's key. + pub key: u32, + /// The home repository's id. + pub repo_id: String, + /// Open, closed or deleted. + pub state: BoardState, + /// `None` when it could not be read (a sealed board without the repo's key). + pub name: Option, + /// The parsed definition; `None` when it could not be read or was refused. + pub spec: Option, + /// Why `spec` is `None`: the rules' refusal ([`SpecError::as_str`]) or `unreadable`. + pub spec_error: Option, + /// The definition is sealed (a private repository's). + pub sealed: bool, + /// The newest revision. + pub newest: BoardRevision, + /// Every member's revision document, oldest first, malformed ones included (a save + /// replaces the signer's own, [`own_revision`], whatever it holds). + pub revisions: Vec, +} + +/// A card as read: the rules' [`CardDoc`] and whether it is a sealed card this reader could +/// not open (its column, rank and fields unknown, not empty). +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct BoardCard { + /// The card. + #[serde(flatten)] + pub card: CardDoc, + /// Sealed and not opened here. + #[serde(skip_serializing_if = "std::ops::Not::not")] + pub unreadable: bool, + /// The document's `$revision`, when the read has it: what tells a read that lags behind + /// this client's own write ([`Collab::write_card`], §3.2). + #[serde(skip_serializing_if = "Option::is_none")] + pub revision: Option, +} + +/// A card a [`Collab`]'s write landed: its document, the revision it wrote, and what it holds. +#[derive(Debug, Clone)] +pub struct LandedCard { + /// The signer's card document. + pub document_id: String, + /// The `$revision` the write made. + pub revision: u64, + /// What it holds. + pub card: CardDoc, +} + +/// What a card write over `docs` (a fresh read of item `item_id`'s cards) builds on (§3.2, +/// the web's `overIfAhead`): the newest card this reader opens (one it cannot open holds values +/// it cannot carry over), or, while the read lacks `landed` (the last card this client's write +/// of the item landed), holds an older revision of it, or (its revision unknown) holds other +/// content, `landed` (a member's own back-to-back writes must not undo each other); with the +/// signer's own document (the read's, or the landed one's) and the revision it holds. +#[must_use] +pub fn card_base_of( + landed: Option<&LandedCard>, + item_id: &str, + docs: &ItemCardDocs, +) -> (Option, Option, u64) { + let read_revision = |id: &str| { + docs.cards + .iter() + .find(|c| c.card.id == id) + .and_then(|c| c.revision) + }; + if let Some(l) = landed { + let read = docs.cards.iter().find(|c| c.card.id == l.document_id); + let behind = match read { + None => true, + Some(c) => match c.revision { + Some(r) => r < l.revision, + None => { + (&c.card.col, &c.card.rank, &c.card.f, c.card.state) + != (&l.card.col, &l.card.rank, &l.card.f, l.card.state) + } + }, + }; + if behind { + return ( + Some(l.card.clone()), + Some(l.document_id.clone()), + l.revision, + ); + } + } + let readable: Vec = docs + .cards + .iter() + .filter(|c| !c.unreadable) + .map(|c| c.card.clone()) + .collect(); + ( + newest_cards(&readable).get(item_id).map(|c| (*c).clone()), + docs.own.clone(), + docs.own.as_deref().and_then(read_revision).unwrap_or(0), + ) +} + +/// The repositories of `docs` (`repo` documents read by `repo`'s owner) whose boards `repo`'s +/// items show in their sidebar (§5.6): `repo` itself and the owner's other public ones, by id. +#[must_use] +pub fn sidebar_homes_of(repo: &RepoRef, docs: &[FetchedDocument]) -> BTreeMap { + let mut homes = BTreeMap::from([(repo.id().to_string(), repo.clone())]); + for d in docs { + if let Ok(r) = crate::resolve::repo_ref_from_doc(repo.forge(), d) { + if r.owner_id() == repo.owner_id() && r.visibility != Visibility::Private { + homes.entry(r.id().to_string()).or_insert(r); + } + } + } + homes +} + +/// One board and every card on it, as [`Collab::board`] reads them. +#[derive(Debug, Clone)] +pub struct BoardRead { + /// The definition. + pub board: Board, + /// Every member's card, ordered by (`$updatedAt`, `$id`). + pub cards: Vec, + /// The newest `$updatedAt` among the cards (0 when none): a later read starts here. + pub since: i64, +} + +/// Every member's card for one item on one board, and the `$id` of the signer's own card +/// document (whatever it holds). +#[derive(Debug, Clone)] +pub struct ItemCardDocs { + /// The cards that read. + pub cards: Vec, + /// The signer's own document. + pub own: Option, +} + +/// One board an issue or PR is on, for its sidebar (§5.6). +#[derive(Debug, Clone)] +pub struct ItemBoard { + /// The board's home repository. + pub home: RepoRef, + /// The board. + pub board: Board, + /// Every member's card for the item on it. + pub cards: Vec, + /// The newest of them, if any. + pub card: Option, +} + +/// A board's items, ready to fold (the web's `BoardItemSet`). +#[derive(Debug, Clone, Default)] +pub struct BoardItemSet { + /// The items. + pub items: Vec, + /// Items shown as "a private item": in a private repository this reader cannot open, or + /// members-only and not opened. + pub hidden: BTreeSet, + /// Card items that are no issue or PR this reader can find (dropped from the board). + pub missing: BTreeSet, + /// A source's list stopped short (more than [`PR_PAGES`] pages of pull requests). + pub partial: bool, + /// Some source repository has closed items older than were kept. + pub has_older_closed: bool, +} + +/// A board with its cards, items and fold at `now`: what `dg board view` shows and what a move +/// ranks against. +#[derive(Debug, Clone)] +pub struct BoardSnapshot { + /// The board and its cards. + pub read: BoardRead, + /// Its items. + pub items: BoardItemSet, + /// The fold; `None` when the definition did not open. + pub fold: Option, + /// The time it was folded at (ms). + pub now: i64, +} + +impl BoardSnapshot { + /// The item with `id`. + #[must_use] + pub fn item(&self, id: &str) -> Option<&BoardItem> { + self.items.items.iter().find(|i| i.id == id) + } + + /// Where item `id` shows. + #[must_use] + pub fn placement(&self, id: &str) -> Option<&Placement> { + self.fold.as_ref()?.items.iter().find(|p| p.id == id) + } + + /// Every item's placement by its id (empty when the definition did not open). + #[must_use] + pub fn placement_index(&self) -> HashMap<&str, &Placement> { + self.fold + .as_ref() + .map(|f| f.items.iter().map(|p| (p.id.as_str(), p)).collect()) + .unwrap_or_default() + } + + /// Column `col`'s visible cards in rank order, with their effective ranks (what a move + /// ranks between). + #[must_use] + pub fn column(&self, col: u8) -> Vec { + let Some(fold) = &self.fold else { + return Vec::new(); + }; + let placed = self.placement_index(); + fold.columns + .iter() + .filter(|c| c.id == col) + .flat_map(|c| c.items.iter()) + .map(|id| RankedCard { + id: id.clone(), + rank: placed + .get(id.as_str()) + .map_or_else(String::new, |p| p.rank.clone()), + }) + .collect() + } +} + +/// The signer's own revision of a board, if they wrote one. +#[must_use] +pub fn own_revision<'b>(board: &'b Board, me: &str) -> Option<&'b BoardRevision> { + board.revisions.iter().find(|r| r.owner_id == me) +} + +/// Whether `role` may place cards: move, rank, set fields, add, archive, remove (§5.1). +#[must_use] +pub fn can_place_cards(role: Option) -> bool { + matches!(role, Some(Role::Maintainer | Role::Writer | Role::Triage)) +} + +/// Whether `role` may create, edit, close or delete a board and save views (§5.1). +#[must_use] +pub fn can_edit_boards(role: Option) -> bool { + matches!(role, Some(Role::Maintainer | Role::Writer)) +} + +// --------------------------------------------------------------------------------------------- +// Documents +// --------------------------------------------------------------------------------------------- + +/// A u32 integer field, or `None`. +fn u32_of(d: &FetchedDocument, field: &str) -> Option { + d.field_u64(field).and_then(|n| u32::try_from(n).ok()) +} + +/// `$updatedAt` (both timestamps are required on these types; `$createdAt` covers a row read +/// before `$updatedAt` was). +#[allow(clippy::cast_possible_wrap)] // ms since 1970 +fn updated_at(d: &FetchedDocument) -> i64 { + d.updated_at.or(d.created_at).unwrap_or(0) as i64 +} + +/// How a reader opens a stored sealed board or card: `None` when it holds no keys (a public +/// repository's sealed document, or a reader without the private repository's). +pub type Opener<'k> = Option<&'k dyn Fn(&sealed::StoredBoardDoc) -> Opened>; + +/// A stored document's sealed form for [`sealed::open`]; `None` when it names no owner or also +/// carries a plaintext content field ([`Bind::plaintext_fields`]: malformed, skipped). +fn stored_of(d: &FetchedDocument, bind: Bind) -> Option { + if bind + .plaintext_fields() + .iter() + .any(|f| d.fields.contains_key(*f)) + { + return None; + } + Some(sealed::StoredBoardDoc { + bind, + owner_id: platform::decode_identifier(&d.owner_id).ok()?, + epoch: u32_of(d, "epoch"), + enc: d.field_bytes("enc"), + plaintext: false, + }) +} + +/// A `board` document as the rules read it ([`BoardDoc`]) and whether it is sealed, opened +/// where it is; `None` when malformed (plaintext content beside `enc`, a private board without +/// `enc`, a broken seal), which every reader skips. A sealed board `open` cannot open reads with +/// no name or spec. Parity: the web's `boardDocOf`. +#[must_use] +pub fn board_doc_of( + d: &FetchedDocument, + visibility: Visibility, + open: Opener<'_>, +) -> Option<(BoardDoc, bool)> { + let key = u32_of(d, "key").filter(|k| *k > 0)?; + let state = d.field_u64("state").filter(|s| *s <= 2)?; + let mut doc = BoardDoc { + id: d.id.clone(), + owner_id: d.owner_id.clone(), + updated_at: updated_at(d), + key, + state: i64::try_from(state).ok()?, + name: None, + spec: None, + }; + if !d.fields.contains_key("enc") { + if visibility == Visibility::Private { + return None; + } + doc.name = d.field_str("name"); + doc.spec = d.field_str("spec"); + return Some((doc, false)); + } + let stored = stored_of(d, Bind::Board { key })?; + let Some(open) = open else { + return Some((doc, true)); + }; + match open(&stored) { + Opened::Malformed => return None, + Opened::Readable(Content::Board(f)) => { + doc.name = Some(f.name); + doc.spec = Some(f.spec); + } + Opened::Readable(Content::Card(_)) | Opened::Unreadable(_) => {} + } + Some((doc, true)) +} + +/// A `card` document as the rules read it, opened where it is sealed: one `open` cannot open +/// keeps its `state`, marked unreadable. `None` when malformed (as [`board_doc_of`]). +#[must_use] +pub fn card_doc_of( + d: &FetchedDocument, + visibility: Visibility, + open: Opener<'_>, +) -> Option { + let board = u32_of(d, "board").filter(|b| *b > 0)?; + let state = d.field_u64("state").filter(|s| *s <= 2)?; + let item_bytes = d.field_bytes32("item")?; + let mut card = CardDoc { + id: d.id.clone(), + owner_id: d.owner_id.clone(), + updated_at: updated_at(d), + item: platform::encode_identifier(item_bytes), + col: None, + rank: None, + f: None, + state: i64::try_from(state).ok()?, + }; + if !d.fields.contains_key("enc") { + if visibility == Visibility::Private { + return None; + } + card.col = d + .field_u64("col") + .filter(|c| *c <= 255) + .and_then(|c| i64::try_from(c).ok()); + card.rank = d.field_str("rank"); + card.f = d.field_str("f"); + return Some(BoardCard { + card, + unreadable: false, + revision: d.revision, + }); + } + let bind = Bind::Card { + board, + item: item_bytes, + }; + let stored = stored_of(d, bind)?; + let unread = |card| { + Some(BoardCard { + card, + unreadable: true, + revision: d.revision, + }) + }; + let Some(open) = open else { + return unread(card); + }; + match open(&stored) { + Opened::Malformed => None, + Opened::Readable(Content::Card(f)) => { + card.col = f.col.map(i64::from); + card.rank = f.rank; + card.f = f.f; + Some(BoardCard { + card, + unreadable: false, + revision: d.revision, + }) + } + Opened::Readable(Content::Board(_)) | Opened::Unreadable(_) => unread(card), + } +} + +/// The boards `docs` (one repository's `board` documents) define: per key the newest revision +/// ([`newest_boards`]), ascending by key, deleted ones only `with_deleted`. `read` is +/// [`board_doc_of`] with the reader's opener. +pub fn boards_of( + repo_id: &str, + docs: &[FetchedDocument], + read: impl Fn(&FetchedDocument) -> Option<(BoardDoc, bool)>, + with_deleted: bool, +) -> Vec { + let opened: Vec<(BoardDoc, bool)> = docs.iter().filter_map(read).collect(); + let sealed: HashMap<&str, bool> = opened.iter().map(|(d, s)| (d.id.as_str(), *s)).collect(); + // every revision document, the skipped ones too: a write replaces the signer's own + let mut by_key: BTreeMap> = BTreeMap::new(); + for d in docs { + if let Some(key) = u32_of(d, "key") { + by_key.entry(key).or_default().push(BoardRevision { + id: d.id.clone(), + owner_id: d.owner_id.clone(), + updated_at: updated_at(d), + }); + } + } + let docs: Vec = opened.iter().map(|(d, _)| d.clone()).collect(); + newest_boards(&docs, with_deleted) + .into_iter() + .map(|d| { + let parsed = d.spec.as_deref().map(parse_spec); + let mut revisions = by_key.get(&d.key).cloned().unwrap_or_default(); + revisions.sort_by(|a, b| (a.updated_at, &a.id).cmp(&(b.updated_at, &b.id))); + Board { + key: d.key, + repo_id: repo_id.to_string(), + state: BoardState::of(d.state), + name: d.name.clone(), + spec_error: match &parsed { + None => Some("unreadable".into()), + Some(Err(e)) => Some(e.as_str().into()), + Some(Ok(_)) => None, + }, + spec: parsed.and_then(std::result::Result::ok), + sealed: sealed.get(d.id.as_str()).copied().unwrap_or(false), + newest: BoardRevision { + id: d.id.clone(), + owner_id: d.owner_id.clone(), + updated_at: d.updated_at, + }, + revisions, + } + }) + .collect() +} + +/// `held` with `fresh` merged in by `$id`: a card is replaced in place (same `$id`, a later +/// `$updatedAt`), so the later of two copies wins; a copy read twice (a `>=` boundary) is kept +/// once. Ordered by (`$updatedAt`, `$id`). +#[must_use] +pub fn merge_cards(held: &[BoardCard], fresh: &[BoardCard]) -> Vec { + let mut by_id: HashMap<&str, &BoardCard> = HashMap::new(); + for c in held.iter().chain(fresh) { + match by_id.get(c.card.id.as_str()) { + Some(prev) if c.card.updated_at < prev.card.updated_at => {} + _ => { + by_id.insert(&c.card.id, c); + } + } + } + let mut out: Vec = by_id.into_values().cloned().collect(); + out.sort_by(|a, b| (a.card.updated_at, &a.card.id).cmp(&(b.card.updated_at, &b.card.id))); + out +} + +/// The newest `$updatedAt` of `cards`, or 0. +#[must_use] +pub fn cards_since(cards: &[BoardCard]) -> i64 { + cards.iter().map(|c| c.card.updated_at).max().unwrap_or(0) +} + +/// The rules' cards of `cards`. +#[must_use] +pub fn card_docs(cards: &[BoardCard]) -> Vec { + cards.iter().map(|c| c.card.clone()).collect() +} + +// --------------------------------------------------------------------------------------------- +// Items (§2.3, §2.4) +// --------------------------------------------------------------------------------------------- + +/// The `$createdAt` of `transitions`' latest move into closed or merged. +#[must_use] +#[allow(clippy::cast_possible_wrap)] // ms since 1970 +pub fn closed_at_of(transitions: &[crate::rules::v2::Transition]) -> Option { + transitions + .iter() + .filter(|t| matches!(t.kind, ISSUE_CLOSE | PR_CLOSE | PR_MERGE | PR_DRAFT_CLOSE)) + .map(|t| t.created_at as i64) + .max() +} + +/// An issue as the board reads it (the web's `boardItemOfIssue`). `label` names its repository. +#[must_use] +#[allow(clippy::cast_possible_wrap)] // ms since 1970 +pub fn board_item_of_issue(v: &IssueView, repo_id: &str, label: &str) -> BoardItem { + let open = v.state.open; + BoardItem { + id: v.issue.document_id.clone(), + number: u64::from(v.issue.number), + repo_id: repo_id.to_string(), + repo: Some(label.to_string()), + kind: ItemKind::Issue, + state: if open { + ItemState::Open + } else { + ItemState::Closed + }, + created_at: v.issue.created_at as i64, + closed_at: if open { + None + } else { + closed_at_of(&v.log.transitions) + }, + title: v.issue.title.clone(), + labels: v.state.labels.iter().cloned().collect(), + assignees: v.state.assignees.iter().cloned().collect(), + milestone: fold_thread_meta_v2(&v.log.events).milestone, + author: v.issue.author.clone(), + } +} + +/// A pull request as the board reads it (the web's `boardItemOfPull`). +#[must_use] +#[allow(clippy::cast_possible_wrap)] // ms since 1970 +pub fn board_item_of_patch(v: &PatchView, repo_id: &str, label: &str) -> BoardItem { + let state = if v.state.merged { + ItemState::Merged + } else if v.state.open { + ItemState::Open + } else { + ItemState::Closed + }; + BoardItem { + id: v.patch.document_id.clone(), + number: u64::from(v.patch.number), + repo_id: repo_id.to_string(), + repo: Some(label.to_string()), + kind: ItemKind::Pr, + state, + created_at: v.patch.created_at as i64, + closed_at: (state != ItemState::Open) + .then(|| closed_at_of(&v.log.transitions)) + .flatten(), + title: v.patch.title.clone(), + labels: v.state.labels.iter().cloned().collect(), + assignees: v.state.assignees.iter().cloned().collect(), + milestone: v.review.milestone.clone(), + author: v.patch.author.clone(), + } +} + +/// A placeholder for an item this reader cannot open ("a private item"): only what is plaintext +/// about it. +#[must_use] +pub fn placeholder(id: &str, repo_id: &str, kind: ItemKind) -> BoardItem { + BoardItem { + id: id.to_string(), + number: 0, + repo_id: repo_id.to_string(), + repo: None, + kind, + state: ItemState::Open, + created_at: 0, + closed_at: None, + title: String::new(), + labels: Vec::new(), + assignees: Vec::new(), + milestone: None, + author: String::new(), + } +} + +/// Which kinds a board's sources read in each source repository (absent `r`: `home`). +#[must_use] +pub fn source_kinds(spec: &BoardSpec, home: &str) -> BTreeMap> { + use crate::rules::boards::SourceKind; + let mut out: BTreeMap> = BTreeMap::new(); + for s in &spec.sources { + let kinds = out + .entry(s.r.clone().unwrap_or_else(|| home.to_string())) + .or_default(); + if s.k != SourceKind::Pulls { + kinds.insert(ItemKind::Issue); + } + if s.k != SourceKind::Issues { + kinds.insert(ItemKind::Pr); + } + } + out +} + +/// The items of one source repository a board keeps (§2.4, the web's first walk): every open +/// one; the closed and merged ones inside the auto-archive window (`arch` days before `now`; +/// older ones are archived), or with `arch` 0 the [`CLOSED_PER_REPO`] most recently closed; +/// with `older`, the next [`CLOSED_PER_REPO`] closed ones past those (what the web's +/// `loadOlderClosed` reads for a view asking for `is:archived`); and every closed one a card +/// names (`carded`). `all` is every item of the repository of the sources' kinds. Returns the +/// kept items and whether older closed ones were left out. +#[must_use] +#[allow(clippy::implicit_hasher)] // the caller's set of carded ids +pub fn select_source_items( + all: Vec, + arch: u16, + carded: &HashSet<&str>, + now: i64, + older: bool, +) -> (Vec, bool) { + let (mut kept, mut closed): (Vec, Vec) = + all.into_iter().partition(|i| i.state == ItemState::Open); + // newest closed first; an unknown close time last + closed.sort_by(|a, b| { + b.closed_at + .unwrap_or(i64::MIN) + .cmp(&a.closed_at.unwrap_or(i64::MIN)) + .then_with(|| a.id.cmp(&b.id)) + }); + let cutoff = now - i64::from(arch) * DAY_MS; + let recent = |n: usize, i: &BoardItem| { + if arch > 0 { + i.closed_at.is_some_and(|at| at >= cutoff) + } else { + n < CLOSED_PER_REPO + } + }; + // the first walk's closed items; with `older`, the next stretch past them + let first = closed + .iter() + .enumerate() + .take_while(|(n, i)| recent(*n, i)) + .count(); + let reach = if older { + first + CLOSED_PER_REPO + } else { + first + }; + let mut left_out = false; + for (n, i) in closed.into_iter().enumerate() { + if n < reach || carded.contains(i.id.as_str()) { + kept.push(i); + } else { + left_out = true; + } + } + (kept, left_out) +} + +// --------------------------------------------------------------------------------------------- +// Write checks (§2.7, §3) +// --------------------------------------------------------------------------------------------- + +/// What a board definition the rules refuse is called. +fn spec_problem(e: SpecError) -> &'static str { + match e { + SpecError::Json => "the board definition is not valid JSON", + SpecError::Version => "the board definition is of a version this build does not write", + SpecError::Size => "a board definition is at most 4096 bytes", + SpecError::Desc => "a board description is at most 1024 characters", + SpecError::Columns => "a board has 1 to 20 columns", + SpecError::Column => "a column needs a unique name of 1-63 characters and an id of 1-255", + SpecError::Def => "the default column is not one of the board's columns", + SpecError::Done => "the Done column is not one of the board's columns", + SpecError::Sources => "a board has at most 5 sources", + SpecError::Source => { + "a source names issues, pull requests or both, with a query of at most 512 characters" + } + SpecError::Fields => "a board has at most 12 fields", + SpecError::Field => { + "a field needs a unique name and an id of 1-255, and may not be named like a query key" + } + SpecError::Options => "a select field has 1-30 options with unique names", + SpecError::Views => "a board has at most 8 views", + SpecError::View => { + "a view's grouping, swimlanes, sort and columns must name the board's own fields" + } + SpecError::Arch => "auto-archive is 0 to 3650 days", + } +} + +/// E201 for a board write the board or the schema refuses, before anything is signed. +fn refused(message: impl Into) -> Error { + UserError::new(codes::USAGE, message) + .note("checked before anything was signed; nothing was written or paid") + .into() +} + +/// The trimmed name and canonical definition JSON a board write stores, or the refusal (the +/// web's `checkBoardInput`). +pub fn check_board_input(name: &str, spec: &BoardSpec) -> Result { + let name = name.trim(); + if !is_board_name(name) { + return Err(refused( + "a board name is 1-63 characters, with no control characters", + )); + } + let spec = serialize_spec(spec).map_err(|e| refused(spec_problem(e)))?; + Ok(BoardFields { + name: name.to_string(), + spec, + }) +} + +/// A new board's key (§2.1): with an `intent`, derived from it and the repository (the web's +/// `newBoardKey`: `sha256("dash-forge board key\0" ‖ repoId ‖ "\0" ‖ intent ‖ "\0" ‖ attempt)`, +/// big-endian, 0 read as 1), so a retry of one create names the same board; else random. +pub fn new_board_key(repo_id: &str, intent: Option<&str>, attempt: u32) -> Result { + let bytes = if let Some(i) = intent { + use sha2::Digest as _; + let h = sha2::Sha256::digest( + format!("dash-forge board key\u{0}{repo_id}\u{0}{i}\u{0}{attempt}").as_bytes(), + ); + [h[0], h[1], h[2], h[3]] + } else { + let r = crate::private::keys::rnd32()?; + [r[0], r[1], r[2], r[3]] + }; + let k = u32::from_be_bytes(bytes); + Ok(if k == 0 { 1 } else { k }) +} + +fn refuse_unless_open(board: &Board) -> Result<()> { + match board.state { + BoardState::Open => Ok(()), + BoardState::Deleted => Err(refused("this board was deleted")), + BoardState::Closed => Err(UserError::new( + codes::USAGE, + "this board is closed: reopen it to change it", + ) + .fix(format!("`dg board close {} --reopen`", board.key)) + .note("checked before anything was signed; nothing was written or paid") + .into()), + } +} + +/// E313 for a board whose definition did not open or parse here. +fn unreadable(board: &Board, what: &str) -> Error { + let code = if board.spec_error.as_deref() == Some("unreadable") { + codes::MEMBERS_ONLY + } else { + codes::INVALID_CONFIG + }; + UserError::new( + code, + format!("this board's definition can't be read here, so {what}"), + ) + .cause(match board.spec_error.as_deref() { + Some("unreadable") | None => "it is sealed with keys this reader does not hold".into(), + Some(e) => format!("its definition is refused by the board rules ({e})"), + }) + .into() +} + +/// The item a card names: its id and its repository (for the cross-repository confirm, §3.3). +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct CardItem { + /// The item's `$id`. + pub id: String, + /// Its repository's id. + pub repo_id: String, +} + +impl CardItem { + /// `item`'s. + #[must_use] + pub fn of(item: &BoardItem) -> Self { + Self { + id: item.id.clone(), + repo_id: item.repo_id.clone(), + } + } +} + +/// What a card write changes; everything else is carried over from the item's newest card. +#[derive(Debug, Clone, Default, PartialEq)] +pub struct CardPatch { + /// The column id; 0 for "No status". + pub col: Option, + /// An explicit rank (§2.6). + pub rank: Option, + /// Field values by field id: `Some` sets one, `None` clears it. + pub fields: BTreeMap>, + /// 0 active, 1 archived, 2 removed. + pub state: Option, +} + +impl CardPatch { + /// A patch setting only `state`. + #[must_use] + pub fn state(state: i64) -> Self { + Self { + state: Some(state), + ..Self::default() + } + } +} + +/// Whether a card for an item of `item_repo_id` on a board of `home` must be confirmed first +/// (§3.3): `item` is plaintext and indexed, so a private repository's card naming another +/// repository's item tells everyone that the private repository tracks it. +#[must_use] +pub fn cross_repo_card_needs_confirm(home: &RepoRef, item_repo_id: &str) -> bool { + home.visibility == Visibility::Private && item_repo_id != home.id() +} + +/// What [`cross_repo_card_needs_confirm`] warns of. +pub const CROSS_REPO_WARNING: &str = "this board is in a private repository: placing an item of another repository on it shows everyone that this repository tracks that item"; + +fn refuse_unless_confirmed(home: &RepoRef, item_repo_id: &str, confirmed: bool) -> Result<()> { + if cross_repo_card_needs_confirm(home, item_repo_id) && !confirmed { + return Err( + UserError::new(codes::CONFIRMATION_REQUIRED, CROSS_REPO_WARNING) + .fix("confirm at the prompt, or pass --yes") + .note("checked before anything was signed; nothing was written or paid") + .into(), + ); + } + Ok(()) +} + +/// A scalar as the JSON value a card stores. +fn json_of(v: &Scalar) -> Option { + match v { + Scalar::Num(x) => serde_json::Number::from_f64(*x).map(serde_json::Value::Number), + Scalar::Text(t) => Some(serde_json::Value::String(t.clone())), + } +} + +/// Refuse a patch the board or the schema would refuse (the web's `checkPatch`). +pub fn check_patch(spec: &BoardSpec, patch: &CardPatch) -> Result<()> { + if patch + .col + .is_some_and(|c| c != 0 && !spec.columns.iter().any(|x| x.id == c)) + { + return Err(refused("that column is not on this board")); + } + if patch.rank.as_deref().is_some_and(|r| !is_explicit_rank(r)) { + return Err(refused("a rank is 1-63 rank digits, not ending in 0")); + } + if patch + .state + .is_some_and(|s| ![CARD_ACTIVE, CARD_ARCHIVED, CARD_REMOVED].contains(&s)) + { + return Err(refused("a card is active, archived or removed")); + } + for (id, v) in &patch.fields { + let Some(field) = spec.field(*id) else { + return Err(refused("that field is not on this board")); + }; + if let Some(v) = v { + if json_of(v).and_then(|j| field_value_ok(field, &j)).is_none() { + return Err(refused(format!( + "that is not a valid value for {}", + field.name + ))); + } + } + } + Ok(()) +} + +/// The card a patch makes (the web's `patchedCard`'s result). +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct PatchedCard { + /// The column. + pub col: Option, + /// The explicit rank. + pub rank: Option, + /// The field values' JSON. + pub f: Option, + /// The state. + pub state: i64, +} + +/// The card `patch` makes over `base` (the item's newest card, any member's, or none): its +/// column, rank and state replaced where given, its field values merged (`None` clears one). +pub fn patched_card( + spec: &BoardSpec, + base: Option<&CardDoc>, + patch: &CardPatch, +) -> Result { + let mut values = parse_field_values(base.and_then(|b| b.f.as_deref()), spec); + for (id, v) in &patch.fields { + match v { + Some(v) => values.insert(*id, v.clone()), + None => values.remove(id), + }; + } + let f = serialize_field_values(&values, spec) + .ok_or_else(|| refused("these field values are over 2048 bytes"))?; + let rank = patch.rank.clone().or_else(|| { + base.and_then(|b| b.rank.clone()) + .filter(|r| is_explicit_rank(r)) + }); + let col = patch + .col + .or_else(|| base.and_then(|b| b.col).and_then(|c| u8::try_from(c).ok())); + Ok(PatchedCard { + col, + rank, + f: (f != "{}").then_some(f), + state: patch + .state + .or_else(|| base.map(|b| b.state)) + .unwrap_or(CARD_ACTIVE), + }) +} + +// --------------------------------------------------------------------------------------------- +// Ranks (§2.6, §5.2) +// --------------------------------------------------------------------------------------------- + +/// A card in a column's shown order: its item and its effective rank (the fold's). +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct RankedCard { + /// The item's `$id`. + pub id: String, + /// Its effective rank. + pub rank: String, +} + +/// The rank that drops a card at position `index` (0 = the top) of `column`, the column's cards +/// in rank order without the one moving (the web's `rankForDrop`): the top is [`top_rank`] +/// (above the sourced pool), the bottom [`bottom_rank`] (below it), elsewhere +/// [`rank_between`] the two neighbours. +pub fn rank_for_drop( + column: &[RankedCard], + index: usize, +) -> std::result::Result { + let at = index.min(column.len()); + if column.is_empty() { + return top_rank(None); + } + if at == 0 { + return top_rank(Some(&column[0].rank)); + } + if at == column.len() { + return bottom_rank(Some(&column[at - 1].rank)); + } + rank_between(&column[at - 1].rank, &column[at].rank) +} + +/// Where a move puts a card in its column. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum DropAt { + /// At the top. + Top, + /// At the bottom. + Bottom, + /// Just before this item. + Before(String), + /// Just after this item. + After(String), +} + +/// The rank that drops `item` at `at` in `column` (the target column's cards in rank order; +/// the moving card itself may be among them and is left out). `None` when `at` names an item +/// that is not in the column. +#[must_use] +pub fn rank_at( + column: &[RankedCard], + item: &str, + at: &DropAt, +) -> Option> { + let others: Vec = column.iter().filter(|c| c.id != item).cloned().collect(); + let pos = |id: &str| others.iter().position(|c| c.id == id); + let index = match at { + DropAt::Top => 0, + DropAt::Bottom => others.len(), + DropAt::Before(id) => pos(id)?, + DropAt::After(id) => pos(id)? + 1, + }; + Some(rank_for_drop(&others, index)) +} + +/// What a [`RankError`] tells the user (the web's `RANK_PROBLEM`). +fn rank_problem(e: RankError) -> Error { + match e { + RankError::Invalid => refused("the neighbouring ranks are not ranks"), + RankError::Order => refused("the neighbours are out of order: read the board again"), + RankError::Rerank => refused( + "there is no room left between these cards: re-rank this column first (move the cards to its top or bottom)", + ), + } +} + +/// How many of the writes to `items` create a card (the signer has none for it) and how many +/// replace one: what is priced first. +#[must_use] +pub fn plan_card_writes(cards: &[BoardCard], me: &str, items: &[String]) -> (usize, usize) { + let mine: HashSet<&str> = cards + .iter() + .filter(|c| c.card.owner_id == me) + .map(|c| c.card.item.as_str()) + .collect(); + let creates = items + .iter() + .filter(|id| !mine.contains(id.as_str())) + .count(); + (creates, items.len() - creates) +} + +/// The items "move open items to the next iteration" moves (§5.4): every open item on the +/// board (not archived) whose iteration field `field_id` is the current iteration at `now`, +/// outside the Done column; and that next iteration's index. `None` when there is no current +/// iteration (or the field is not an iteration field). +#[must_use] +pub fn next_iteration_plan( + spec: &BoardSpec, + field_id: u8, + items: &[BoardItem], + placements: &[Placement], + now: i64, +) -> Option<(i64, Vec)> { + let field = spec.field(field_id).filter(|f| f.kind == FieldType::Iter)?; + let current = iteration_at(field, now)?; + if current + 1 > ITER_INDEX_MAX { + return None; + } + let by_id: HashMap<&str, &BoardItem> = items.iter().map(|i| (i.id.as_str(), i)).collect(); + let want = Scalar::from(current); + let moving = placements + .iter() + .filter_map(|p| { + let item = by_id.get(p.id.as_str())?; + let open = item.state == ItemState::Open && p.on && p.archived.is_none(); + let in_done = spec.done != 0 && p.col == spec.done; + (open && !in_done && p.fields.get(&field_id) == Some(&want)).then(|| CardItem::of(item)) + }) + .collect(); + Some((current + 1, moving)) +} + +/// An existing item a quick add names (§5.3, the web's `parseItemReference`): `#12`, +/// `owner/name#12`, or an issue, PR or number link of the web app +/// (`/repo/issue/?owner=…&name=…&number=12`); `None` for anything else. The owner and name are +/// as written, resolved by the caller. +#[must_use] +pub fn parse_item_reference(text: &str) -> Option { + let t = text.trim(); + let number = |s: &str| -> Option { + ((1..=10).contains(&s.len()) && s.bytes().all(|b| b.is_ascii_digit())) + .then(|| s.parse().ok()) + .flatten() + }; + if let Some(n) = t.strip_prefix('#') { + return Some(ItemReference { + repo: None, + number: number(n)?, + }); + } + if let Some((repo, n)) = t.rsplit_once('#') { + let plain = |s: &str| { + !s.is_empty() && !s.contains(|c: char| c.is_whitespace() || c == '/' || c == '#') + }; + if let Some((owner, name)) = repo.split_once('/') { + if plain(owner) && plain(name) && !t.contains("://") { + return Some(ItemReference { + repo: Some((owner.to_string(), name.to_string())), + number: number(n)?, + }); + } + } + } + // a link of the web app: `/repo/issue/?owner=…&name=…&number=12` + let (_, rest) = t.split_once("://")?; + let path_query = &rest[rest.find('/')?..]; + let (path, query) = path_query.split_once('?')?; + let query = query.split('#').next().unwrap_or_default(); + let path = path.strip_suffix('/').unwrap_or(path); + if !["/repo/issue", "/repo/pull", "/repo/number"].contains(&path) { + return None; + } + let param = |k: &str| { + query + .split('&') + .filter_map(|kv| kv.split_once('=')) + .find(|(key, _)| *key == k) + .map(|(_, v)| percent_decode(v)) + }; + Some(ItemReference { + repo: Some((param("owner")?, param("name")?)), + number: number(¶m("number")?)?, + }) +} + +/// `%xx` and `+` decoded (a link's query value); a `%` without two hex digits kept as written. +fn percent_decode(s: &str) -> String { + let hex = |b: u8| { + char::from(b) + .to_digit(16) + .and_then(|d| u8::try_from(d).ok()) + }; + let bytes = s.as_bytes(); + let mut out = Vec::with_capacity(bytes.len()); + let mut i = 0; + while i < bytes.len() { + let pair = (bytes[i] == b'%') + .then(|| Some(hex(*bytes.get(i + 1)?)? * 16 + hex(*bytes.get(i + 2)?)?)) + .flatten(); + match (bytes[i], pair) { + (_, Some(b)) => { + out.push(b); + i += 2; + } + (b'+', None) => out.push(b' '), + (b, None) => out.push(b), + } + i += 1; + } + String::from_utf8_lossy(&out).into_owned() +} + +/// An item a quick add names: its repository (`owner`, `name`) when given, and its number. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct ItemReference { + /// `(owner, name)` as written; `None`: the board's home repository. + pub repo: Option<(String, String)>, + /// The issue or PR number. + pub number: u32, +} + +// --------------------------------------------------------------------------------------------- +// Outcomes +// --------------------------------------------------------------------------------------------- + +/// The outcome of a board write. +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct BoardWritten { + /// The board's key. + pub key: u32, + /// The signer's revision document. + pub document_id: String, + /// A new document (the signer's first revision of this board), or a replace of theirs. + pub created: bool, + /// `false` when the stored revision already held the change (nothing signed or paid). + pub changed: bool, +} + +/// The outcome of a card write. +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct CardWritten { + /// The item. + pub item: String, + /// The signer's card document. + pub document_id: String, + /// A new document, or a replace of the signer's own. + pub created: bool, + /// `false` when the stored card already held the change (nothing signed or paid). + pub changed: bool, + /// The column written. + pub col: Option, + /// The rank written. + pub rank: Option, + /// The field values written. + pub f: Option, + /// The state written. + pub state: i64, +} + +/// The outcome of a write to several cards: each item's, in order; the first failure stops the +/// rest. +#[derive(Debug)] +pub struct BulkWritten { + /// What landed. + pub written: Vec, + /// The item whose write failed, and why. + pub failed: Option<(String, Error)>, + /// Items not written because an earlier write failed. + pub skipped: Vec, +} + +/// The outcome of [`Collab::quick_add_issue`]: the new issue, as the board reads it, and its +/// card (`Err` when only the issue landed: place it again). +#[derive(Debug)] +pub struct QuickAdded { + /// The new issue. + pub item: BoardItem, + /// Its card, or why it was not written. + pub card: std::result::Result, +} + +/// E702 when the network's Forge has no boards (no forge-meta, or one before UPDATE-3). +fn no_boards(repo: &RepoRef) -> Error { + UserError::new( + codes::NOT_DEPLOYED, + format!( + "boards are not available for {} on this network yet", + repo.display() + ), + ) + .cause("this network's Forge contracts have no `board` and `card` documents (the boards update is not registered here)") + .into() +} + +// --------------------------------------------------------------------------------------------- +// The service +// --------------------------------------------------------------------------------------------- + +/// The two forge-collab item types, in the order the web looks an id or number up in. +const ITEM_DOCS: [(&str, ItemKind); 2] = [(DOC_ISSUE, ItemKind::Issue), (DOC_PATCH, ItemKind::Pr)]; + +/// The owner's repositories an item's sidebar read takes, at most, as the homes its boards may +/// live in (the web's `OWNER_REPO_PAGES` pages of 100). +pub const OWNER_REPO_ROWS: usize = 300; +/// Cards one `card.onItem` read of an item's sidebar follows at most (the web's +/// `ITEM_CARD_PAGES` pages of 100). +pub const ITEM_CARD_ROWS: usize = 300; +/// Pull request pages (100 each) a source repository's read follows at most (the web reads its +/// open pull requests' list as far, `OPEN_PAGES`). +pub const PR_PAGES: usize = 30; + +/// `content`'s set fields: a create's properties. +fn present(content: &BTreeMap>) -> BTreeMap { + content + .iter() + .filter_map(|(k, v)| v.clone().map(|v| (k.clone(), v))) + .collect() +} + +impl Collab<'_> { + /// The contract that holds `board` and `card` (forge-meta), or E702 when this network's + /// has none. + pub async fn board_contract(&self, repo: &RepoRef) -> Result { + let Some(id) = repo.forge().contract_id_of(DOC_BOARD) else { + return Err(no_boards(repo)); + }; + let contract = self.client().fetch_contract(id).await?; + if !contract.has_document_type(DOC_BOARD) || !contract.has_document_type(DOC_CARD) { + return Err(no_boards(repo)); + } + Ok(contract) + } + + /// The keys a reader of `repo` opens sealed boards and cards with (the web's `openerOf`): + /// a private repository's (a member's); for a repository made public, the epoch keys its + /// owner published (`private-repos.md` §18.3), which open what was sealed while it was + /// private; none for any other public repository. + async fn board_keys(&self, repo: &RepoRef) -> Result>> { + if repo.visibility == Visibility::Private { + return Ok(Some(self.keyring(repo).await?)); + } + Ok( + match self + .published_keys(repo, super::v2::Unopened::NotAMember) + .await + { + super::v2::DocKeys::Held(kr, _) => Some(kr), + super::v2::DocKeys::None(_) => None, + }, + ) + } + + /// `f` given the reader's [`Opener`] for `repo` ([`Self::board_keys`]). + async fn with_opener(&self, repo: &RepoRef, f: impl FnOnce(Opener<'_>) -> R) -> Result { + let keys = self.board_keys(repo).await?; + let open = |s: &sealed::StoredBoardDoc| { + keys.as_ref().map_or(Opened::Malformed, |k| k.open_board(s)) + }; + let opener: Opener<'_> = keys + .as_ref() + .map(|_| &open as &dyn Fn(&sealed::StoredBoardDoc) -> Opened); + Ok(f(opener)) + } + + /// `docs` of `repo` as [`Board`]s. + async fn boards_from( + &self, + repo: &RepoRef, + docs: &[FetchedDocument], + with_deleted: bool, + ) -> Result> { + self.with_opener(repo, |o| { + boards_of( + repo.id(), + docs, + |d| board_doc_of(d, repo.visibility, o), + with_deleted, + ) + }) + .await + } + + /// `docs` of `repo` as cards, the malformed dropped. + async fn cards_from(&self, repo: &RepoRef, docs: &[FetchedDocument]) -> Result> { + self.with_opener(repo, |o| { + docs.iter() + .filter_map(|d| card_doc_of(d, repo.visibility, o)) + .collect() + }) + .await + } + + /// Every `board` document of `repo` (`board.byKey`, `repoId ==`), as stored; only key `key` + /// when given. + async fn board_docs(&self, repo: &RepoRef, key: Option) -> Result> { + let contract = self.board_contract(repo).await?; + let mut filters = vec![Self::repo_filter(repo)?]; + if let Some(k) = key { + filters.push(QueryFilter::eq("key", FieldValue::integer(u64::from(k)))); + } + self.client() + .query_all_documents( + &contract, + DOC_BOARD, + &filters, + &[QueryOrder::asc("key"), QueryOrder::asc("$ownerId")], + ) + .await + } + + /// Every board of `repo`: per key the newest revision over every member's, ascending by + /// key, open and closed; deleted ones only `with_deleted`. + pub async fn boards(&self, repo: &RepoRef, with_deleted: bool) -> Result> { + let docs = self.board_docs(repo, None).await?; + self.boards_from(repo, &docs, with_deleted).await + } + + /// Board `key` of `repo` as its newest revision defines it (every member's revision read + /// fresh), or `None` when it has none. A deleted board reads as deleted. + pub async fn board_definition(&self, repo: &RepoRef, key: u32) -> Result> { + let docs = self.board_docs(repo, Some(key)).await?; + Ok(self + .boards_from(repo, &docs, true) + .await? + .into_iter() + .next()) + } + + /// The `card.recent` documents of board `key` of `repo`, oldest change first (from + /// `since` ms, inclusive). + async fn recent_cards( + &self, + repo: &RepoRef, + key: u32, + since: Option, + ) -> Result> { + let contract = self.board_contract(repo).await?; + let mut filters = vec![ + Self::repo_filter(repo)?, + QueryFilter::eq("board", FieldValue::integer(u64::from(key))), + ]; + if let Some(t) = since { + filters.push(QueryFilter::gte( + "$updatedAt", + FieldValue::uint64(u64::try_from(t).unwrap_or(0)), + )); + } + let docs = self + .client() + .query_all_documents( + &contract, + DOC_CARD, + &filters, + &[QueryOrder::asc("board"), QueryOrder::asc("$updatedAt")], + ) + .await?; + self.cards_from(repo, &docs).await + } + + /// Board `key` of `repo`: its definition and every card on it, every member's + /// (`card.recent`), or `None` when the board has no revision. Cards of a board whose + /// definition did not open are still read (their states are plaintext). + pub async fn board(&self, repo: &RepoRef, key: u32) -> Result> { + let Some(board) = self.board_definition(repo, key).await? else { + return Ok(None); + }; + let cards = merge_cards(&[], &self.recent_cards(repo, key, None).await?); + let since = cards_since(&cards); + Ok(Some(BoardRead { + board, + cards, + since, + })) + } + + /// The cards of board `key` written or replaced at or after `since` ms: `>=`, since several + /// cards can share a block time, so a caller merges them by `$id` ([`merge_cards`]). + pub async fn cards_since( + &self, + repo: &RepoRef, + key: u32, + since: i64, + ) -> Result> { + self.recent_cards(repo, key, Some(since)).await + } + + /// Every member's card for `item_id` on board `key` of `repo`, read fresh (`card.onItem`): + /// what a card write applies its change to (§3.2), and `me`'s own card document, found among + /// the raw rows (one this reader skips as malformed is still the one the unique index holds). + pub async fn item_card_docs( + &self, + repo: &RepoRef, + key: u32, + item_id: &str, + me: &str, + ) -> Result { + let contract = self.board_contract(repo).await?; + let docs = self + .client() + .query_all_documents( + &contract, + DOC_CARD, + &[ + QueryFilter::eq( + "item", + FieldValue::identifier(platform::decode_identifier(item_id)?), + ), + Self::repo_filter(repo)?, + QueryFilter::eq("board", FieldValue::integer(u64::from(key))), + ], + &[QueryOrder::asc("repoId"), QueryOrder::asc("board")], + ) + .await?; + let own = docs.iter().find(|d| d.owner_id == me).map(|d| d.id.clone()); + Ok(ItemCardDocs { + cards: self.cards_from(repo, &docs).await?, + own, + }) + } + + /// The repositories whose boards `repo`'s items show in their sidebar (§5.6, the web's + /// `sidebarHomes`): `repo` itself and its owner's other public repositories (at most + /// [`OWNER_REPO_ROWS`]; a private one's boards are sealed with keys this read does not + /// hold), by id. + async fn sidebar_homes(&self, repo: &RepoRef) -> Result> { + let core = self.core_contract(repo).await?; + let owner = platform::decode_identifier(repo.owner_id())?; + let docs = self + .client() + .query_documents_up_to( + &core, + crate::resolve::DOC_REPO, + &[QueryFilter::eq("$ownerId", FieldValue::identifier(owner))], + &[QueryOrder::asc("name")], + OWNER_REPO_ROWS, + ) + .await?; + Ok(sidebar_homes_of( + repo, + &docs[..docs.len().min(OWNER_REPO_ROWS)], + )) + } + + /// The boards issue or PR `item_id` of `repo` has a card on, whose home is `repo` or + /// another public repository of the same owner (§5.6: a stranger's board naming the issue + /// is never read, nor a private repository's, sealed with keys this read does not hold). + /// The owner's repositories are read first ([`Self::sidebar_homes`]), then `card.onItem` + /// with `item ==` and `repoId in` them (100 a read, at most [`ITEM_CARD_ROWS`] each), so + /// cards anyone else writes naming the item cost this read nothing. Deleted boards are + /// left out, closed ones kept. Ordered by home repository (`repo` first), then key. + pub async fn item_boards(&self, repo: &RepoRef, item_id: &str) -> Result> { + let contract = self.board_contract(repo).await?; + let item = FieldValue::identifier(platform::decode_identifier(item_id)?); + let homes = self.sidebar_homes(repo).await?; + let ids: Vec<&String> = homes.keys().collect(); + let mut by_home: BTreeMap> = BTreeMap::new(); + for chunk in ids.chunks(100) { + let in_homes = chunk + .iter() + .map(|id| platform::decode_identifier(id).map(FieldValue::identifier)) + .collect::>>()?; + let docs = self + .client() + .query_documents_up_to( + &contract, + DOC_CARD, + &[ + QueryFilter::eq("item", item.clone()), + QueryFilter::in_list("repoId", in_homes), + ], + &[QueryOrder::asc("repoId"), QueryOrder::asc("board")], + ITEM_CARD_ROWS, + ) + .await?; + for d in docs.into_iter().take(ITEM_CARD_ROWS) { + if let Some(home) = d.field_bytes32("repoId").map(platform::encode_identifier) { + if homes.contains_key(&home) { + by_home.entry(home).or_default().push(d); + } + } + } + } + let mut ordered: Vec<(String, Vec)> = by_home.into_iter().collect(); + ordered.sort_by_key(|(h, _)| (h != repo.id(), h.clone())); + let mut out = Vec::new(); + for (home_id, home_docs) in ordered { + let Some(home) = homes.get(&home_id).cloned() else { + continue; + }; + let mut by_key: BTreeMap> = BTreeMap::new(); + for d in home_docs { + if let Some(k) = u32_of(&d, "board").filter(|k| *k > 0) { + by_key.entry(k).or_default().push(d); + } + } + for (key, key_docs) in by_key { + let Some(board) = self.board_definition(&home, key).await? else { + continue; + }; + if board.state == BoardState::Deleted { + continue; + } + let cards = self.cards_from(&home, &key_docs).await?; + let docs = card_docs(&cards); + let newest = newest_cards(&docs).get(item_id).map(|c| c.id.clone()); + let card = newest.and_then(|id| cards.iter().find(|c| c.card.id == id).cloned()); + out.push(ItemBoard { + home: home.clone(), + board, + cards, + card, + }); + } + } + Ok(out) + } + + /// Every item of `repo` of `kinds`, as the board reads it: every issue, and every pull + /// request, newest first, page after page ([`Self::list_patch_views_before`], at most + /// [`PR_PAGES`] pages, as the web reads its open ones); `true` when that cap left some + /// pull requests unread. + async fn repo_items( + &self, + repo: &RepoRef, + kinds: &BTreeSet, + ) -> Result<(Vec, bool)> { + let label = repo.display(); + let mut items = Vec::new(); + let mut partial = false; + if kinds.contains(&ItemKind::Issue) { + let read = self.issues_with_state_read(repo).await?; + items.extend( + read.rows + .iter() + .map(|v| board_item_of_issue(v, repo.id(), &label)), + ); + } + if kinds.contains(&ItemKind::Pr) { + let mut seen = HashSet::new(); + let mut before: Option = None; + for page in 0..PR_PAGES { + let (listed, _) = self.list_patch_views_before(repo, 0, before).await?; + // the page's oldest row, readable or not: the next page starts at its time + let oldest = listed + .rows + .iter() + .map(|(v, _)| v.patch.created_at) + .chain(listed.members_only.iter().map(|m| m.created_at)) + .min(); + let mut added = 0; + for (v, _) in &listed.rows { + if seen.insert(v.patch.document_id.clone()) { + items.push(board_item_of_patch(v, repo.id(), &label)); + added += 1; + } + } + added += listed + .members_only + .iter() + .filter(|m| seen.insert(m.document_id.clone())) + .count(); + if !listed.more { + break; + } + // a full page with no readable time to go on from, or one that added nothing + // (one time shared by 100+ PRs), or the last page read: some PRs are left out + if oldest.is_none() || (added == 0 && before == oldest) || page + 1 == PR_PAGES { + partial = true; + break; + } + before = oldest; + } + } + Ok((items, partial)) + } + + /// Whether this reader opens `repo`'s items on a board of `home`: a public repository, the + /// home, or another private repository whose keys this signer holds (a member of both, + /// §2.5); remembered in `known`. A key this signer does not hold is no error: those items + /// show as "a private item". + async fn opens_items( + &self, + repo: &RepoRef, + home: &RepoRef, + known: &mut BTreeMap, + ) -> Result { + if repo.visibility != Visibility::Private || repo.id() == home.id() { + return Ok(true); + } + if let Some(held) = known.get(repo.id()) { + return Ok(*held); + } + // a keyring loads for a reader with no key too: holding one is `require_key`'s answer + let held = match self.keyring(repo).await { + Ok(kr) => kr.require_key(repo).is_ok(), + Err(Error::User(_)) => false, + Err(e) => return Err(e), + }; + known.insert(repo.id().to_string(), held); + Ok(held) + } + + /// Repository `repo_id`: `home` itself, one already read, or resolved. + async fn repo_of( + &self, + home: &RepoRef, + known: &mut BTreeMap>, + repo_id: &str, + ) -> Option { + if repo_id == home.id() { + return Some(home.clone()); + } + if let Some(r) = known.get(repo_id) { + return r.clone(); + } + let r = crate::resolve::resolve_id(self.client(), repo_id) + .await + .ok(); + known.insert(repo_id.to_string(), r.clone()); + r + } + + /// Where card-named item `id` is: its forge-collab document, its kind and its repository; + /// `None` when it is no issue or PR of a repository this reader finds. + async fn locate_carded( + &self, + home: &RepoRef, + known: &mut BTreeMap>, + collab: &LoadedContract, + id: &str, + ) -> Result> { + for (doc_type, kind) in ITEM_DOCS { + let Some(d) = self.client().fetch_document(collab, doc_type, id).await? else { + continue; + }; + let Some(repo_id) = d.field_bytes32("repoId").map(platform::encode_identifier) else { + return Ok(None); + }; + return Ok(self + .repo_of(home, known, &repo_id) + .await + .map(|repo| (d, kind, repo))); + } + Ok(None) + } + + /// Every item of the board `spec` of `home` describes (§2.3, §2.4; the web's + /// `loadBoardItems`): its source repositories' items ([`select_source_items`]; with + /// `archived`, the next stretch of older closed ones too, as the web reads for a view asking + /// for `is:archived`), then every item `cards` name that the sources did not bring, by id in + /// its own repository (a placeholder where it cannot be opened). A source repository that is + /// private, not the home and not one whose keys this signer holds ([`Self::opens_items`]) + /// contributes nothing (its items show as placeholders where a card names them). + pub async fn board_items( + &self, + home: &RepoRef, + spec: &BoardSpec, + cards: &[CardDoc], + now: i64, + archived: bool, + ) -> Result { + let carded: HashSet<&str> = cards.iter().map(|c| c.item.as_str()).collect(); + let mut known = BTreeMap::new(); + let mut opens = BTreeMap::new(); + let mut set = BoardItemSet::default(); + let mut by_id: BTreeMap = BTreeMap::new(); + for (repo_id, kinds) in source_kinds(spec, home.id()) { + let Some(repo) = self.repo_of(home, &mut known, &repo_id).await else { + continue; + }; + if !self.opens_items(&repo, home, &mut opens).await? { + continue; + } + let (all, partial) = self.repo_items(&repo, &kinds).await?; + set.partial |= partial; + let (kept, older) = select_source_items(all, spec.arch, &carded, now, archived); + set.has_older_closed |= older; + for i in kept { + by_id.insert(i.id.clone(), i); + } + } + let mut wanted: Vec<&str> = carded + .iter() + .copied() + .filter(|id| !by_id.contains_key(*id)) + .collect(); + wanted.sort_unstable(); + let collab = self.collab_contract(home).await?; + for id in wanted { + let Some((d, kind, repo)) = self.locate_carded(home, &mut known, &collab, id).await? + else { + set.missing.insert(id.to_string()); + continue; + }; + let item = if self.opens_items(&repo, home, &mut opens).await? { + self.item_by_doc(&repo, kind, &d).await? + } else { + None + }; + if let Some(i) = item { + by_id.insert(i.id.clone(), i); + } else { + // located but not shown: a private or members-only item this reader cannot open + set.hidden.insert(id.to_string()); + by_id.insert(id.to_string(), placeholder(id, repo.id(), kind)); + } + } + set.items = by_id.into_values().collect(); + Ok(set) + } + + /// The board item of the issue or PR `d` of `repo`, read as its list reads it; `None` when + /// this reader cannot open it (members-only, or not the well-formed item its number names). + /// A failed read is an error, never "a private item". + async fn item_by_doc( + &self, + repo: &RepoRef, + kind: ItemKind, + d: &FetchedDocument, + ) -> Result> { + use super::v2::{TargetKind, TargetRead}; + let label = repo.display(); + let (target, number) = match kind { + ItemKind::Issue => (TargetKind::Issue, issue_from_doc(d).number), + ItemKind::Pr => (TargetKind::Patch, patch_from_doc(d).number), + }; + let Some(TargetRead::Readable(read)) = self.target_read(repo, target, number).await? else { + return Ok(None); + }; + if read.id != d.id { + return Ok(None); + } + Ok(match kind { + ItemKind::Issue => self + .issue_view(repo, number) + .await? + .map(|v| board_item_of_issue(&v, repo.id(), &label)), + ItemKind::Pr => { + let v = self.patch_view(repo, patch_from_doc(&read)).await?; + Some(board_item_of_patch(&v, repo.id(), &label)) + } + }) + } + + /// Board `key` of `repo` read whole and folded at `now`: its definition and cards, its items + /// ([`Self::board_items`], with the older closed ones when `archived`: a view asking for + /// `is:archived`) and the fold. `None` when the board has no revision. + pub async fn board_snapshot( + &self, + repo: &RepoRef, + key: u32, + now: i64, + archived: bool, + ) -> Result> { + let Some(read) = self.board(repo, key).await? else { + return Ok(None); + }; + let docs = card_docs(&read.cards); + let (items, fold) = match &read.board.spec { + Some(spec) => { + let items = self.board_items(repo, spec, &docs, now, archived).await?; + let fold = + crate::rules::boards::fold_board(spec, repo.id(), &items.items, &docs, now); + (items, Some(fold)) + } + None => (BoardItemSet::default(), None), + }; + Ok(Some(BoardSnapshot { + read, + items, + fold, + now, + })) + } + + /// Issue or PR `number` of `repo` (issues first, as the web's `resolveItemByNumber`; `kind` + /// asks for one), its id and kind, members-only ones included; `None` when neither exists. + pub async fn resolve_item_by_number( + &self, + repo: &RepoRef, + number: u32, + kind: Option, + ) -> Result> { + let collab = self.collab_contract(repo).await?; + for (doc_type, k) in ITEM_DOCS { + if kind.is_some_and(|want| want != k) { + continue; + } + let docs = self + .client() + .query_documents( + &collab, + doc_type, + &[ + Self::repo_filter(repo)?, + QueryFilter::eq("number", FieldValue::integer(u64::from(number))), + ], + &[QueryOrder::asc("number")], + 1, + None, + ) + .await?; + if let Some(d) = docs.into_iter().next() { + return Ok(Some((d.id, k))); + } + } + Ok(None) + } + + // --- writes --------------------------------------------------------------------------- + + /// Replace the signer's own `doc_type` document `id` with `content` and `state`, restating + /// the role it claims (`r`) after the role pre-check: what [`Collab::write`] does for a + /// create, for a replace. `false` when it already held all of it (nothing signed). + #[allow(clippy::too_many_arguments)] // the document, what it holds, and the role it needs + async fn replace_own( + &self, + repo: &RepoRef, + contract: &LoadedContract, + doc_type: &str, + needs: Role, + id: &str, + content: &BTreeMap>, + state: i64, + ) -> Result { + self.require_role(repo, needs, &format!("write this {doc_type}")) + .await?; + let mut changes = content.clone(); + changes.insert( + "state".into(), + Some(FieldValue::integer(state.unsigned_abs())), + ); + let claimed = members::claimed_role(self.cached_role(repo).await?, false); + if contract.has_property(doc_type, members::CLAIMED_ROLE) { + changes.insert( + members::CLAIMED_ROLE.to_string(), + Some(FieldValue::integer(claimed)), + ); + } + self.engine()? + .replace_document(contract, doc_type, id, &changes) + .await + } + + /// The content `bind` stores for `repo`: plaintext in a public repository; sealed into + /// `epoch` and `enc` under the current write epoch in a private one. Every content field is + /// stated (`None` removes it), so a replace drops the other form's fields. + async fn board_content( + &self, + repo: &RepoRef, + bind: Bind, + content: &Content, + ) -> Result>> { + let mut out = BTreeMap::new(); + if repo.visibility == Visibility::Private { + let kr = self.keyring(repo).await?; + let w = kr.writer(repo)?; + let owner = platform::decode_identifier(&self.signer_id()?)?; + let enc = sealed::seal(w.write_keys(), &owner, &bind, content)?; + out.insert( + "epoch".into(), + Some(FieldValue::integer(u64::from(w.write_epoch()))), + ); + out.insert("enc".into(), Some(FieldValue::bytes(enc))); + for k in bind.plaintext_fields() { + out.insert((*k).into(), None); + } + return Ok(out); + } + out.insert("epoch".into(), None); + out.insert("enc".into(), None); + let text = |s: &Option| s.as_deref().map(FieldValue::text); + match content { + Content::Board(f) => { + out.insert("name".into(), Some(FieldValue::text(&f.name))); + out.insert("spec".into(), Some(FieldValue::text(&f.spec))); + } + Content::Card(f) => { + out.insert( + "col".into(), + f.col.map(|c| FieldValue::integer(u64::from(c))), + ); + out.insert("rank".into(), text(&f.rank)); + out.insert("f".into(), text(&f.f)); + } + } + Ok(out) + } + + /// Write the signer's revision of board `key`: replace their own revision of `board` (the + /// board as read) when they have one, else create one. `state` is plaintext; the name and + /// definition sealed in a private repository. + async fn write_board_revision( + &self, + repo: &RepoRef, + key: u32, + fields: BoardFields, + state: BoardState, + board: Option<&Board>, + ) -> Result { + let contract = self.board_contract(repo).await?; + let content = self + .board_content(repo, Bind::Board { key }, &Content::Board(fields)) + .await?; + let me = self.signer_id()?; + if let Some(own) = board.and_then(|b| own_revision(b, &me)) { + let changed = self + .replace_own( + repo, + &contract, + DOC_BOARD, + Role::Writer, + &own.id, + &content, + state.code(), + ) + .await?; + return Ok(BoardWritten { + key, + document_id: own.id.clone(), + created: false, + changed, + }); + } + self.require_role(repo, Role::Writer, "create, edit, close or delete boards") + .await?; + let mut props = present(&content); + props.insert("key".into(), FieldValue::integer(u64::from(key))); + props.insert( + "state".into(), + FieldValue::integer(state.code().unsigned_abs()), + ); + let id = self.write(repo, &contract, DOC_BOARD, props).await?; + Ok(BoardWritten { + key, + document_id: id, + created: true, + changed: true, + }) + } + + /// Create a board in `repo` (§2.1): a new key no revision names (every raw row counted, + /// the malformed too), and the signer's first revision of it. With an `intent` the key is + /// derived from it ([`new_board_key`]), so a retry of one create names the same board: when + /// the signer's own revision alone holds it, the first attempt landed and is replaced + /// (`created` false), never a second board. Maintainers and writers only. + pub async fn create_board( + &self, + repo: &RepoRef, + name: &str, + spec: &BoardSpec, + intent: Option<&str>, + ) -> Result { + let fields = check_board_input(name, spec)?; + self.require_role(repo, Role::Writer, "create boards") + .await?; + let me = self.signer_id()?; + for attempt in 0..8 { + let key = new_board_key(repo.id(), intent, attempt)?; + let taken = self.board_docs(repo, Some(key)).await?; + if taken.is_empty() { + return self + .write_board_revision(repo, key, fields, BoardState::Open, None) + .await; + } + // a retry of this create whose first attempt landed: its own revision holds the key + if intent.is_some() && taken.len() == 1 && taken[0].owner_id == me { + let board = self.board_definition(repo, key).await?; + return self + .write_board_revision(repo, key, fields, BoardState::Open, board.as_ref()) + .await; + } + } + Err(Error::Config( + "could not find an unused board key; try again".into(), + )) + } + + /// Board `key` of `repo`, or E102. + async fn existing_board(&self, repo: &RepoRef, key: u32) -> Result { + self.board_definition(repo, key).await?.ok_or_else(|| { + UserError::new( + codes::NOT_FOUND, + format!("no board {key} in {}", repo.display()), + ) + .fix(format!( + "`dg board list {}` lists its boards", + repo.display() + )) + .into() + }) + } + + /// Save a change to board `key` (its name, its definition, or both): read its newest + /// revision fresh, apply the change, and replace the signer's own revision (or create one). + /// Refused for a closed or deleted board, or one whose definition did not open. + pub async fn save_board( + &self, + repo: &RepoRef, + key: u32, + name: Option<&str>, + spec: Option<&BoardSpec>, + ) -> Result { + let board = self.existing_board(repo, key).await?; + refuse_unless_open(&board)?; + let (Some(old_name), Some(old_spec)) = (&board.name, &board.spec) else { + return Err(unreadable(&board, "it can't be edited")); + }; + let fields = check_board_input(name.unwrap_or(old_name), spec.unwrap_or(old_spec))?; + self.write_board_revision(repo, key, fields, BoardState::Open, Some(&board)) + .await + } + + /// Open, close (read-only, listed under Closed) or delete board `key` (§3.1 `state`): a new + /// revision with the newest one's name and definition. A writer may close or delete a + /// maintainer's board, as with labels. A deleted board stays deleted. + pub async fn set_board_state( + &self, + repo: &RepoRef, + key: u32, + state: BoardState, + ) -> Result { + let board = self.existing_board(repo, key).await?; + if board.state == BoardState::Deleted { + return Err(refused("this board was deleted")); + } + let (Some(name), Some(spec)) = (&board.name, &board.spec) else { + return Err(unreadable(&board, "it can't be changed")); + }; + let fields = check_board_input(name, spec)?; + self.write_board_revision(repo, key, fields, state, Some(&board)) + .await + } + + /// Write the signer's card for `item` on `board` of `repo` (§3.2): refused for a closed + /// board, a patch the board does not admit, or (unconfirmed) a private home's + /// cross-repository item; then the definition and the item's cards are read fresh, `patch` + /// is applied to its base ([`Self::card_base`]: the newest card this reader opens, or this + /// `Collab`'s last landed card while the read lags behind it), and the signer's own card is + /// replaced (or created: a create that meets the signer's card made meanwhile re-reads, + /// applies the patch over the newest card then, and replaces it instead). + pub async fn write_card( + &self, + repo: &RepoRef, + board: &Board, + item: &CardItem, + patch: &CardPatch, + confirm_cross_repo: bool, + ) -> Result { + // what the caller's copy of the board refuses is refused at once; the fresh read decides + refuse_unless_open(board)?; + refuse_unless_confirmed(repo, &item.repo_id, confirm_cross_repo)?; + let item_bytes = platform::decode_identifier(&item.id)?; + self.require_role(repo, Role::Triage, "place items on boards") + .await?; + let contract = self.board_contract(repo).await?; + let me = self.signer_id()?; + // the definition read with the cards: a field, option or column another member added + // since is kept, and a board closed meanwhile is read-only + let fresh = self.existing_board(repo, board.key).await?; + refuse_unless_open(&fresh)?; + let Some(spec) = &fresh.spec else { + return Err(unreadable(&fresh, "its cards can't be changed")); + }; + check_patch(spec, patch)?; + let landed_key = format!("{}:{}:{}", repo.id(), board.key, item.id); + let bind = Bind::Card { + board: board.key, + item: item_bytes, + }; + let docs = self.item_card_docs(repo, board.key, &item.id, &me).await?; + let (base, own, revision) = self.card_base(&landed_key, &item.id, &docs); + let mut next = patched_card(spec, base.as_ref(), patch)?; + let mut content = self.card_content(repo, bind, &next).await?; + let replace = async |id: &str, content: &BTreeMap>, state| { + self.replace_own(repo, &contract, DOC_CARD, Role::Triage, id, content, state) + .await + }; + let (document_id, created, changed, revision) = if let Some(own) = own { + let changed = replace(&own, &content, next.state).await?; + (own, false, changed, revision + u64::from(changed)) + } else { + let mut props = present(&content); + props.insert("board".into(), FieldValue::integer(u64::from(board.key))); + props.insert("item".into(), FieldValue::identifier(item_bytes)); + props.insert( + "state".into(), + FieldValue::integer(next.state.unsigned_abs()), + ); + match self.write(repo, &contract, DOC_CARD, props).await { + Ok(id) => (id, true, true, 1), + // The signer's card for this item appeared since the read (another device): + // apply the patch over the newest card now, that device's included, and + // replace it. + Err(Error::DuplicateUniqueIndex(m)) => { + let again = self.item_card_docs(repo, board.key, &item.id, &me).await?; + let (base, own, revision) = self.card_base(&landed_key, &item.id, &again); + let Some(own) = own else { + return Err(Error::DuplicateUniqueIndex(m)); + }; + next = patched_card(spec, base.as_ref(), patch)?; + content = self.card_content(repo, bind, &next).await?; + let changed = replace(&own, &content, next.state).await?; + (own, false, changed, revision + u64::from(changed)) + } + Err(e) => return Err(e), + } + }; + self.land_card(landed_key, &document_id, revision, &me, &item.id, &next); + Ok(CardWritten { + item: item.id.clone(), + document_id, + created, + changed, + col: next.col, + rank: next.rank.clone(), + f: next.f.clone(), + state: next.state, + }) + } + + /// [`card_base_of`] with this `Collab`'s last landed card for `landed_key`. + fn card_base( + &self, + landed_key: &str, + item_id: &str, + docs: &ItemCardDocs, + ) -> (Option, Option, u64) { + let landed = self + .landed_cards + .lock() + .ok() + .and_then(|m| m.get(landed_key).cloned()); + card_base_of(landed.as_ref(), item_id, docs) + } + + /// A card's stored content for `repo` ([`Self::board_content`]). + async fn card_content( + &self, + repo: &RepoRef, + bind: Bind, + next: &PatchedCard, + ) -> Result>> { + self.board_content( + repo, + bind, + &Content::Card(CardFields { + col: next.col, + rank: next.rank.clone(), + f: next.f.clone(), + }), + ) + .await + } + + /// Remember the card a write landed ([`Self::card_base`]). + fn land_card( + &self, + landed_key: String, + document_id: &str, + revision: u64, + me: &str, + item: &str, + next: &PatchedCard, + ) { + let card = CardDoc { + id: document_id.to_string(), + owner_id: me.to_string(), + updated_at: 0, + item: item.to_string(), + col: next.col.map(i64::from), + rank: next.rank.clone(), + f: next.f.clone(), + state: next.state, + }; + if let Ok(mut m) = self.landed_cards.lock() { + m.insert( + landed_key, + LandedCard { + document_id: document_id.to_string(), + revision, + card, + }, + ); + } + } + + /// Move `item` to column `col`, at `at` in `column` (the target column's cards in rank + /// order, [`BoardSnapshot::column`]): one card write with the new column and rank. Refused + /// before signing when no rank fits (re-rank the column first). + #[allow(clippy::too_many_arguments)] // the board, the item, where, and the confirm + pub async fn move_card( + &self, + repo: &RepoRef, + board: &Board, + item: &CardItem, + col: u8, + column: &[RankedCard], + at: &DropAt, + confirm_cross_repo: bool, + ) -> Result { + let rank = rank_at(column, &item.id, at) + .ok_or_else(|| refused("the card to drop it next to is not in that column"))? + .map_err(rank_problem)?; + let patch = CardPatch { + col: Some(col), + rank: Some(rank), + ..CardPatch::default() + }; + self.write_card(repo, board, item, &patch, confirm_cross_repo) + .await + } + + /// Write each of `writes` in turn, stopping at the first failure. + pub async fn write_cards( + &self, + repo: &RepoRef, + board: &Board, + writes: &[(CardItem, CardPatch)], + confirm_cross_repo: bool, + ) -> BulkWritten { + let mut written = Vec::new(); + for (i, (item, patch)) in writes.iter().enumerate() { + match self + .write_card(repo, board, item, patch, confirm_cross_repo) + .await + { + Ok(w) => written.push(w), + Err(e) => { + return BulkWritten { + written, + failed: Some((item.id.clone(), e)), + skipped: writes[i + 1..].iter().map(|(x, _)| x.id.clone()).collect(), + } + } + } + } + BulkWritten { + written, + failed: None, + skipped: Vec::new(), + } + } + + /// Carry the current iteration's unfinished items into the next (§5.4): + /// [`next_iteration_plan`] over `snapshot`, one write each. + pub async fn move_open_to_next_iteration( + &self, + repo: &RepoRef, + snapshot: &BoardSnapshot, + field_id: u8, + ) -> Result { + let board = &snapshot.read.board; + let (Some(spec), Some(fold)) = (&board.spec, &snapshot.fold) else { + return Err(unreadable(board, "its cards can't be changed")); + }; + let (next, items) = next_iteration_plan( + spec, + field_id, + &snapshot.items.items, + &fold.items, + snapshot.now, + ) + .ok_or_else(|| refused("there is no current iteration to move items from"))?; + let writes: Vec<(CardItem, CardPatch)> = items + .into_iter() + .map(|i| { + let mut p = CardPatch::default(); + p.fields.insert(field_id, Some(Scalar::from(next))); + (i, p) + }) + .collect(); + Ok(self.write_cards(repo, board, &writes, true).await) + } + + /// Quick add (§5.3): `title` makes a real issue in `target` (`None`: the home repository) + /// with the issue create everyone uses, then places it in column `col` at the bottom of + /// `column` (the column's cards in rank order). Two writes; a card that fails after the + /// issue landed is reported in [`QuickAdded::card`], not returned as the error, so the issue + /// is not made twice. + #[allow(clippy::too_many_arguments)] // the board, the title, where, and the confirm + pub async fn quick_add_issue( + &self, + home: &RepoRef, + board: &Board, + title: &str, + col: u8, + column: &[RankedCard], + target: Option<&RepoRef>, + journal_dir: &Path, + confirm_cross_repo: bool, + ) -> Result { + refuse_unless_open(board)?; + let Some(spec) = &board.spec else { + return Err(unreadable(board, "its cards can't be changed")); + }; + check_patch( + spec, + &CardPatch { + col: Some(col), + ..CardPatch::default() + }, + )?; + let target = target.unwrap_or(home); + refuse_unless_confirmed(home, target.id(), confirm_cross_repo)?; + let title = title.trim(); + if title.is_empty() { + return Err(refused("an issue needs a title")); + } + let created = self.create_issue(target, title, "", journal_dir).await?; + let now = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .map_or(0, |d| i64::try_from(d.as_millis()).unwrap_or(i64::MAX)); + let item = BoardItem { + id: created.document_id.clone(), + number: u64::from(created.number), + repo_id: target.id().to_string(), + repo: Some(target.display()), + kind: ItemKind::Issue, + state: ItemState::Open, + created_at: now, + closed_at: None, + title: title.to_string(), + labels: Vec::new(), + assignees: Vec::new(), + milestone: None, + author: self.signer_id()?, + }; + let rank = (!column.is_empty()) + .then(|| rank_at(column, "", &DropAt::Bottom)) + .flatten() + .and_then(std::result::Result::ok); + let patch = CardPatch { + col: Some(col), + rank, + ..CardPatch::default() + }; + let card = self + .write_card(home, board, &CardItem::of(&item), &patch, true) + .await; + Ok(QuickAdded { item, card }) + } +} + +#[cfg(test)] +mod tests; diff --git a/crates/forge-core/src/collab/boards/tests.rs b/crates/forge-core/src/collab/boards/tests.rs new file mode 100644 index 000000000..f31560140 --- /dev/null +++ b/crates/forge-core/src/collab/boards/tests.rs @@ -0,0 +1,896 @@ +//! The board read assembly and write merges (`docs/design/boards.md` §2.4, §3.2), offline: +//! documents as Platform returns them, sealed ones opened with fixed keys. + +use std::collections::{BTreeMap, HashSet}; + +use super::*; +use crate::platform::{encode_identifier, FetchedDocument, FieldValue}; +use crate::private::board::{self as sealed, Bind, BoardFields, CardFields, Content}; +use crate::private::doc::{AnchorRef, OpenContext}; +use crate::private::{EpochKey, EpochKeys}; +use crate::rules::boards::{default_spec, fold_board, BoardItem, ItemKind, ItemState, Scalar}; + +const REPO: [u8; 32] = [0x11; 32]; +const ALICE: [u8; 32] = [0xa1; 32]; +const BOB: [u8; 32] = [0xb2; 32]; +const ITEM: [u8; 32] = [0x44; 32]; + +fn doc(id: u8, owner: [u8; 32], updated: u64, fields: Vec<(&str, FieldValue)>) -> FetchedDocument { + FetchedDocument { + id: encode_identifier([id; 32]), + owner_id: encode_identifier(owner), + created_at: Some(1), + created_at_block_height: Some(1), + updated_at_block_height: Some(1), + updated_at: Some(updated), + fields: fields + .into_iter() + .map(|(k, v)| (k.to_string(), v)) + .collect(), + revision: Some(1), + } +} + +fn spec_json() -> String { + serialize_spec(&default_spec(&encode_identifier(REPO), 0)).unwrap() +} + +fn board_doc( + id: u8, + owner: [u8; 32], + updated: u64, + key: u64, + name: &str, + state: u64, +) -> FetchedDocument { + doc( + id, + owner, + updated, + vec![ + ("repoId", FieldValue::identifier(REPO)), + ("key", FieldValue::integer(key)), + ("name", FieldValue::text(name)), + ("spec", FieldValue::text(spec_json())), + ("state", FieldValue::integer(state)), + ], + ) +} + +fn card_doc(id: u8, owner: [u8; 32], updated: u64, col: u64) -> FetchedDocument { + doc( + id, + owner, + updated, + vec![ + ("repoId", FieldValue::identifier(REPO)), + ("board", FieldValue::integer(7)), + ("item", FieldValue::identifier(ITEM)), + ("col", FieldValue::integer(col)), + ("state", FieldValue::integer(0)), + ], + ) +} + +fn keys() -> (EpochKeys, OpenContext) { + let keys = EpochKeys::derive(&REPO, 0, &EpochKey::from_bytes([3; 32])); + let ctx = OpenContext { + keys: [(0, keys.clone())].into(), + anchors: [( + 0, + AnchorRef { + id: [9; 32], + height: 1, + stated_height: 1, + }, + )] + .into(), + ..OpenContext::default() + }; + (keys, ctx) +} + +#[test] +fn the_newest_revision_names_a_board_and_every_revision_is_kept() { + let docs = vec![ + board_doc(1, ALICE, 10, 7, "Roadmap", 0), + board_doc(2, BOB, 20, 7, "Plan", 0), + board_doc(3, ALICE, 5, 9, "Gone", 2), + // malformed (no state): no board reads it, but it is still Bob's revision of key 9 + doc(4, BOB, 30, vec![("key", FieldValue::integer(9))]), + ]; + let boards = boards_of( + "home", + &docs, + |d| board_doc_of(d, Visibility::Public, None), + false, + ); + assert_eq!(boards.len(), 1); + let b = &boards[0]; + assert_eq!( + (b.key, b.name.as_deref(), b.state), + (7, Some("Plan"), BoardState::Open) + ); + assert_eq!(b.newest.owner_id, encode_identifier(BOB)); + assert_eq!(b.revisions.len(), 2); + assert!(b.revisions[0].updated_at < b.revisions[1].updated_at); + assert!(b.spec.is_some() && b.spec_error.is_none() && !b.sealed); + assert_eq!( + own_revision(b, &encode_identifier(ALICE)).map(|r| r.id.clone()), + Some(encode_identifier([1; 32])) + ); + let all = boards_of( + "home", + &docs, + |d| board_doc_of(d, Visibility::Public, None), + true, + ); + assert_eq!(all.len(), 2); + assert_eq!(all[1].state, BoardState::Deleted); + // the malformed row is still the revision a write by Bob would replace + assert_eq!(all[1].revisions.len(), 2); +} + +#[test] +fn a_refused_definition_reads_as_a_board_without_one() { + let mut d = board_doc(1, ALICE, 10, 7, "Roadmap", 0); + d.fields + .insert("spec".into(), FieldValue::text(r#"{"v":1,"columns":[]}"#)); + let b = &boards_of( + "home", + &[d], + |d| board_doc_of(d, Visibility::Public, None), + false, + )[0]; + assert!(b.spec.is_none()); + assert_eq!(b.spec_error.as_deref(), Some("columns")); +} + +#[test] +fn a_private_board_opens_with_the_keys_and_is_unreadable_without() { + let (keys, ctx) = keys(); + let fields = BoardFields { + name: "Roadmap".into(), + spec: spec_json(), + }; + let enc = sealed::seal( + &keys, + &ALICE, + &Bind::Board { key: 7 }, + &Content::Board(fields), + ) + .unwrap(); + let d = doc( + 1, + ALICE, + 10, + vec![ + ("repoId", FieldValue::identifier(REPO)), + ("key", FieldValue::integer(7)), + ("state", FieldValue::integer(1)), + ("epoch", FieldValue::integer(0)), + ("enc", FieldValue::bytes(enc)), + ], + ); + let open = |s: &sealed::StoredBoardDoc| sealed::open(&ctx, s); + let (b, was_sealed) = board_doc_of(&d, Visibility::Private, Some(&open)).unwrap(); + assert!(was_sealed); + assert_eq!(b.name.as_deref(), Some("Roadmap")); + assert_eq!(b.state, 1); + let (b, _) = board_doc_of(&d, Visibility::Private, None).unwrap(); + assert_eq!((b.name, b.spec), (None, None)); + // plaintext beside enc, and a private board without enc: malformed, skipped + let mut both = d.clone(); + both.fields.insert("name".into(), FieldValue::text("x")); + assert!(board_doc_of(&both, Visibility::Private, Some(&open)).is_none()); + let plain = board_doc(2, ALICE, 10, 7, "Roadmap", 0); + assert!(board_doc_of(&plain, Visibility::Private, Some(&open)).is_none()); + // the same seal moved to another key does not open + let mut moved = d; + moved.fields.insert("key".into(), FieldValue::integer(8)); + let (b, _) = board_doc_of(&moved, Visibility::Private, Some(&open)).unwrap(); + assert!(b.name.is_none()); +} + +/// A repository made public (§18): the boards and cards sealed while it was private open with +/// the epoch keys its owner published (the reader's opener), as the web's `repo.published` +/// opens them; without those keys they read as unreadable, never dropped. +#[test] +fn a_repository_made_public_opens_its_private_era_boards_with_the_published_keys() { + let (keys, published) = keys(); + let enc = sealed::seal( + &keys, + &ALICE, + &Bind::Board { key: 7 }, + &Content::Board(BoardFields { + name: "Roadmap".into(), + spec: spec_json(), + }), + ) + .unwrap(); + let d = doc( + 1, + ALICE, + 10, + vec![ + ("repoId", FieldValue::identifier(REPO)), + ("key", FieldValue::integer(7)), + ("state", FieldValue::integer(0)), + ("epoch", FieldValue::integer(0)), + ("enc", FieldValue::bytes(enc)), + ], + ); + let open = |s: &sealed::StoredBoardDoc| sealed::open(&published, s); + let read = |o| { + boards_of( + "home", + std::slice::from_ref(&d), + |x| board_doc_of(x, Visibility::Public, o), + false, + ) + }; + let b = &read(Some(&open))[0]; + assert!(b.sealed && b.spec.is_some()); + assert_eq!(b.name.as_deref(), Some("Roadmap")); + let b = &read(None)[0]; + assert!(b.sealed && b.name.is_none()); + assert_eq!(b.spec_error.as_deref(), Some("unreadable")); + // and a card of that era keeps its column, so a later write carries it over + let card_enc = sealed::seal( + &keys, + &BOB, + &Bind::Card { + board: 7, + item: ITEM, + }, + &Content::Card(CardFields { + col: Some(2), + rank: Some("Vx".into()), + f: Some(r#"{"1":2}"#.into()), + }), + ) + .unwrap(); + let c = doc( + 2, + BOB, + 11, + vec![ + ("repoId", FieldValue::identifier(REPO)), + ("board", FieldValue::integer(7)), + ("item", FieldValue::identifier(ITEM)), + ("state", FieldValue::integer(0)), + ("epoch", FieldValue::integer(0)), + ("enc", FieldValue::bytes(card_enc)), + ], + ); + let opened = card_doc_of(&c, Visibility::Public, Some(&open)).unwrap(); + assert!(!opened.unreadable); + assert_eq!(opened.card.col, Some(2)); + assert!( + card_doc_of(&c, Visibility::Public, None) + .unwrap() + .unreadable + ); +} + +#[test] +fn a_new_boards_key_is_random_or_derived_from_its_intent() { + // the web's `newBoardKey`: sha256("dash-forge board key\0" ‖ repoId ‖ "\0" ‖ intent ‖ "\0" ‖ attempt) + assert_eq!( + new_board_key("REPOID", Some("intent-1"), 0).unwrap(), + 3_811_880_938 + ); + assert_eq!( + new_board_key("REPOID", Some("intent-1"), 1).unwrap(), + 3_777_027_571 + ); + assert_ne!( + new_board_key("REPOID", None, 0).unwrap(), + new_board_key("REPOID", None, 0).unwrap() + ); +} + +#[test] +fn a_sealed_card_keeps_its_state_when_it_does_not_open() { + let (keys, ctx) = keys(); + let bind = Bind::Card { + board: 7, + item: ITEM, + }; + let fields = CardFields { + col: Some(2), + rank: Some("V".into()), + f: Some(r#"{"1":3}"#.into()), + }; + let enc = sealed::seal(&keys, &BOB, &bind, &Content::Card(fields)).unwrap(); + let d = doc( + 5, + BOB, + 10, + vec![ + ("repoId", FieldValue::identifier(REPO)), + ("board", FieldValue::integer(7)), + ("item", FieldValue::identifier(ITEM)), + ("state", FieldValue::integer(1)), + ("epoch", FieldValue::integer(0)), + ("enc", FieldValue::bytes(enc)), + ], + ); + let open = |s: &sealed::StoredBoardDoc| sealed::open(&ctx, s); + let c = card_doc_of(&d, Visibility::Private, Some(&open)).unwrap(); + assert!(!c.unreadable); + assert_eq!((c.card.col, c.card.rank.as_deref()), (Some(2), Some("V"))); + assert_eq!(c.card.item, encode_identifier(ITEM)); + let c = card_doc_of(&d, Visibility::Private, None).unwrap(); + assert!(c.unreadable); + assert_eq!((c.card.state, c.card.col), (1, None)); + // a public card reads its plaintext; a column past 255 is none + let p = card_doc_of(&card_doc(6, ALICE, 3, 300), Visibility::Public, None).unwrap(); + assert_eq!(p.card.col, None); +} + +#[test] +fn cards_merge_by_id_the_later_copy_winning() { + let read = |d: &FetchedDocument| card_doc_of(d, Visibility::Public, None).unwrap(); + let a1 = read(&card_doc(1, ALICE, 10, 1)); + let a2 = read(&card_doc(1, ALICE, 30, 3)); + let b = read(&card_doc(2, BOB, 20, 2)); + let merged = merge_cards(&[a1.clone(), b.clone()], &[a2.clone(), b.clone()]); + assert_eq!(merged, vec![b.clone(), a2.clone()]); + // an older copy read later does not undo a newer one + assert_eq!( + merge_cards(std::slice::from_ref(&a2), &[a1]), + vec![a2.clone()] + ); + assert_eq!(cards_since(&merged), 30); + assert_eq!(cards_since(&[]), 0); + let me = encode_identifier(ALICE); + assert_eq!( + plan_card_writes(&merged, &me, &[encode_identifier(ITEM), "other".into()]), + (1, 1) + ); +} + +fn base_card(f: Option<&str>, rank: Option<&str>) -> CardDoc { + CardDoc { + id: "c".into(), + owner_id: "o".into(), + updated_at: 1, + item: "i".into(), + col: Some(2), + rank: rank.map(str::to_string), + f: f.map(str::to_string), + state: CARD_ARCHIVED, + } +} + +#[test] +fn a_patch_applies_to_the_newest_card_and_keeps_the_rest() { + let spec = default_spec("home", 0); + let base = base_card(Some(r#"{"1":2,"2":5}"#), Some("V1")); + let mut patch = CardPatch::default(); + patch.fields.insert(1, Some(Scalar::from(3))); + patch.fields.insert(2, None); + let next = patched_card(&spec, Some(&base), &patch).unwrap(); + assert_eq!(next.f.as_deref(), Some(r#"{"1":3}"#)); + assert_eq!( + (next.col, next.rank.as_deref(), next.state), + (Some(2), Some("V1"), CARD_ARCHIVED) + ); + // clearing the last value writes none; a base rank ending in 0 is implicit, not carried + let mut clear = CardPatch::default(); + clear.fields.insert(1, None); + clear.fields.insert(2, None); + let next = patched_card( + &spec, + Some(&base_card(Some(r#"{"1":2}"#), Some("V10"))), + &clear, + ) + .unwrap(); + assert_eq!((next.f, next.rank), (None, None)); + let fresh = patched_card(&spec, None, &CardPatch::state(CARD_REMOVED)).unwrap(); + assert_eq!((fresh.col, fresh.state), (None, CARD_REMOVED)); + assert_eq!( + patched_card(&spec, None, &CardPatch::default()) + .unwrap() + .state, + CARD_ACTIVE + ); +} + +#[test] +fn a_patch_the_board_does_not_admit_is_refused_before_signing() { + let spec = default_spec("home", 0); + let ok = |p: CardPatch| check_patch(&spec, &p).is_ok(); + assert!(ok(CardPatch { + col: Some(0), + ..CardPatch::default() + })); + assert!(!ok(CardPatch { + col: Some(9), + ..CardPatch::default() + })); + assert!(!ok(CardPatch { + rank: Some("V0".into()), + ..CardPatch::default() + })); + assert!(!ok(CardPatch::state(3))); + let field = |id, v: Scalar| { + let mut p = CardPatch::default(); + p.fields.insert(id, Some(v)); + p + }; + assert!(ok(field(1, Scalar::from(4)))); + assert!(!ok(field(1, Scalar::from(5))), "no option 5"); + assert!(!ok(field(9, Scalar::from(1))), "no field 9"); + assert!( + !ok(field(3, Scalar::Text("x".into()))), + "an iteration is a number" + ); + assert!(ok(field(2, Scalar::Num(2.5)))); +} + +#[test] +fn a_board_name_and_definition_are_checked_and_written_canonically() { + let spec = default_spec(&encode_identifier(REPO), 0); + let f = check_board_input(" Roadmap ", &spec).unwrap(); + assert_eq!(f.name, "Roadmap"); + assert_eq!(parse_spec(&f.spec).unwrap(), spec); + assert!(check_board_input(" ", &spec).is_err()); + assert!(check_board_input("a\u{7}b", &spec).is_err()); + assert!(check_board_input(&"x".repeat(64), &spec).is_err()); + let mut bad = spec; + bad.columns.clear(); + assert!(check_board_input("Roadmap", &bad).is_err()); +} + +fn ranked(ids: &[(&str, &str)]) -> Vec { + ids.iter() + .map(|(id, rank)| RankedCard { + id: (*id).into(), + rank: (*rank).into(), + }) + .collect() +} + +#[test] +fn a_move_ranks_between_its_new_neighbours() { + let col = ranked(&[("a", "1"), ("b", "V1"), ("c", "V5"), ("d", "X")]); + let at = |m: &str, d: DropAt| rank_at(&col, m, &d).unwrap().unwrap(); + let top = at("z", DropAt::Top); + assert!(top.as_str() < "1"); + let bottom = at("z", DropAt::Bottom); + assert!(bottom.as_str() > "X"); + let before = at("z", DropAt::Before("c".into())); + assert!("V1" < before.as_str() && before.as_str() < "V5"); + let after = at("z", DropAt::After("c".into())); + assert!("V5" < after.as_str() && after.as_str() < "X"); + // the moving card itself is left out: `b` after `c` goes between `c` and `d` + let b_after_c = at("b", DropAt::After("c".into())); + assert!("V5" < b_after_c.as_str() && b_after_c.as_str() < "X"); + assert!(rank_at(&col, "z", &DropAt::Before("nope".into())).is_none()); + assert!(rank_at(&[], "z", &DropAt::Bottom).unwrap().is_ok()); + // two equal ranks: no room, re-rank + let tie = ranked(&[("a", "V1"), ("b", "V1")]); + assert_eq!( + rank_at(&tie, "z", &DropAt::After("a".into())).unwrap(), + Err(RankError::Rerank) + ); +} + +fn item(id: &str, state: ItemState, closed_at: Option) -> BoardItem { + BoardItem { + id: id.into(), + number: 1, + repo_id: "home".into(), + repo: None, + kind: ItemKind::Issue, + state, + created_at: 0, + closed_at, + title: id.into(), + labels: Vec::new(), + assignees: Vec::new(), + milestone: None, + author: "a".into(), + } +} + +#[test] +fn a_source_keeps_its_open_items_and_its_recently_closed_ones() { + let day = 86_400_000; + let now = 100 * day; + let all = vec![ + item("open", ItemState::Open, None), + item("recent", ItemState::Closed, Some(now - 2 * day)), + item("old", ItemState::Merged, Some(now - 20 * day)), + item("old-carded", ItemState::Closed, Some(now - 30 * day)), + ]; + let carded: HashSet<&str> = ["old-carded"].into(); + let (kept, older) = select_source_items(all.clone(), 14, &carded, now, false); + let ids: Vec<&str> = kept.iter().map(|i| i.id.as_str()).collect(); + assert_eq!(ids, ["open", "recent", "old-carded"]); + assert!(older); + // auto-archive off: the most recently closed CLOSED_PER_REPO + let many: Vec = (0..CLOSED_PER_REPO + 5) + .map(|n| { + item( + &format!("c{n:03}"), + ItemState::Closed, + Some(i64::try_from(n).unwrap()), + ) + }) + .collect(); + let (kept, older) = select_source_items(many, 0, &HashSet::new(), now, false); + assert_eq!(kept.len(), CLOSED_PER_REPO); + assert!(older); + assert!(kept.iter().all(|i| i.id.as_str() >= "c005")); + let (_, older) = select_source_items(all, 365, &HashSet::new(), now, false); + assert!(!older); +} + +/// `dg board view --archived` (a view asking for `is:archived`) keeps the next +/// `CLOSED_PER_REPO` closed items past the window, as the web's "Show older" reads them: an +/// item auto-archived without a card shows. +#[test] +fn a_view_asking_for_archived_items_keeps_the_next_stretch_of_older_closed_ones() { + let day = 86_400_000; + let now = 1_000 * day; + let mut all = vec![ + item("open", ItemState::Open, None), + item("recent", ItemState::Closed, Some(now - 2 * day)), + ]; + // 205 closed past the 14-day window, newest first c000 … c204, none carded + all.extend((0..CLOSED_PER_REPO + 5).map(|n| { + item( + &format!("c{n:03}"), + ItemState::Closed, + Some(now - 30 * day - i64::try_from(n).unwrap() * day), + ) + })); + let (kept, older) = select_source_items(all.clone(), 14, &HashSet::new(), now, false); + assert_eq!(kept.len(), 2); + assert!(older); + let (kept, older) = select_source_items(all.clone(), 14, &HashSet::new(), now, true); + let ids: Vec<&str> = kept.iter().map(|i| i.id.as_str()).collect(); + assert_eq!(ids.len(), 2 + CLOSED_PER_REPO); + assert!(ids.contains(&"c000") && ids.contains(&"c199") && !ids.contains(&"c200")); + assert!(older); + // auto-archive off: the first 200, then 200 more + let (kept, older) = select_source_items(all, 0, &HashSet::new(), now, true); + assert_eq!(kept.len(), 1 + CLOSED_PER_REPO + 6); + assert!(!older); +} + +#[test] +fn source_kinds_merge_per_repository() { + let mut spec = default_spec("home", 0); + spec.sources = vec![ + crate::rules::boards::BoardSource { + r: None, + k: crate::rules::boards::SourceKind::Issues, + q: String::new(), + }, + crate::rules::boards::BoardSource { + r: Some("home".into()), + k: crate::rules::boards::SourceKind::Pulls, + q: String::new(), + }, + crate::rules::boards::BoardSource { + r: Some("other".into()), + k: crate::rules::boards::SourceKind::Issues, + q: String::new(), + }, + ]; + let kinds = source_kinds(&spec, "home"); + assert_eq!(kinds["home"].len(), 2); + assert_eq!( + kinds["other"].iter().copied().collect::>(), + [ItemKind::Issue] + ); +} + +#[test] +fn next_iteration_moves_the_current_iterations_open_unfinished_items() { + let spec = default_spec("home", 0); // Iteration (field 3) from 1969-12-29, 14 days + let now = 20 * 86_400_000; // iteration 1 (index 1) + let items = vec![ + item("move", ItemState::Open, None), + item("done-col", ItemState::Open, None), + item("closed", ItemState::Closed, Some(1)), + item("later", ItemState::Open, None), + ]; + let card = |id: &str, n: u8, f: &str| CardDoc { + id: format!("card-{id}"), + owner_id: "o".into(), + updated_at: 5, + item: id.into(), + col: Some(i64::from(n)), + rank: None, + f: Some(f.into()), + state: CARD_ACTIVE, + }; + let cards = vec![ + card("move", 2, r#"{"3":1}"#), + card("done-col", 3, r#"{"3":1}"#), + card("closed", 2, r#"{"3":1}"#), + card("later", 1, r#"{"3":2}"#), + ]; + let fold = fold_board(&spec, "home", &items, &cards, now); + let (next, moving) = next_iteration_plan(&spec, 3, &items, &fold.items, now).unwrap(); + assert_eq!(next, 2); + assert_eq!( + moving.iter().map(|i| i.id.as_str()).collect::>(), + ["move"] + ); + assert!( + next_iteration_plan(&spec, 1, &items, &fold.items, now).is_none(), + "not an iteration field" + ); +} + +#[test] +fn an_item_reference_is_a_number_a_repo_and_number_or_a_link() { + let r = |t: &str| parse_item_reference(t); + assert_eq!( + r("#12"), + Some(ItemReference { + repo: None, + number: 12 + }) + ); + assert_eq!( + r(" alice/proj#7 "), + Some(ItemReference { + repo: Some(("alice".into(), "proj".into())), + number: 7 + }) + ); + assert_eq!( + r("https://forge.dashhq.org/repo/issue/?owner=alice&name=my%2Dproj&number=3"), + Some(ItemReference { + repo: Some(("alice".into(), "my-proj".into())), + number: 3 + }) + ); + assert_eq!( + r("https://forge.dashhq.org/repo/pull?owner=a&name=b&number=4").map(|x| x.number), + Some(4) + ); + assert_eq!(r("Fix the login page"), None); + assert_eq!(r("#"), None); + assert_eq!(r("#12345678901"), None); + assert_eq!( + r("https://forge.dashhq.org/repo/tree?owner=a&name=b&number=4"), + None + ); +} + +#[test] +fn a_closed_items_close_time_is_its_latest_move_into_closed_or_merged() { + let t = |kind: u8, at: u64| -> crate::rules::v2::Transition { + serde_json::from_value(serde_json::json!({ "kind": kind, "createdAt": at })).unwrap() + }; + assert_eq!( + closed_at_of(&[t(1, 5), t(2, 7), t(1, 9), t(3, 11)]), + Some(9) + ); + assert_eq!(closed_at_of(&[t(14, 5), t(13, 8)]), Some(8)); + assert_eq!(closed_at_of(&[t(2, 5)]), None); +} + +#[test] +fn boards_are_role_gated_like_the_web() { + use crate::collab::v2::gated_write; + // forge-web `lib/rules/roles.ts`: `board` admits r 1 only, `card` 1 or 2 + assert_eq!( + gated_write(DOC_BOARD, &BTreeMap::new()), + Some((Role::Writer, false)) + ); + assert_eq!( + gated_write(DOC_CARD, &BTreeMap::new()), + Some((Role::Triage, false)) + ); + assert!(crate::members::ROLE_GATED_TYPES.contains(&DOC_BOARD)); + assert!(crate::members::ROLE_GATED_TYPES.contains(&DOC_CARD)); + assert!(can_place_cards(Some(Role::Triage)) && !can_place_cards(Some(Role::Reader))); + assert!(can_edit_boards(Some(Role::Writer)) && !can_edit_boards(Some(Role::Triage))); + assert!(!can_place_cards(None) && !can_edit_boards(Some(Role::Bot))); + // a triage member claims r 2 on a card + assert_eq!( + crate::collab::v2::claimed_role_for(DOC_CARD, &BTreeMap::new(), Some(Role::Triage)), + Some(2) + ); +} + +#[test] +fn a_snapshot_lists_a_columns_cards_with_their_ranks() { + let spec = default_spec("home", 0); + let items = vec![ + item("a", ItemState::Open, None), + item("b", ItemState::Open, None), + ]; + let cards = vec![CardDoc { + id: "c".into(), + owner_id: "o".into(), + updated_at: 1, + item: "b".into(), + col: Some(1), + rank: Some("1".into()), + f: None, + state: CARD_ACTIVE, + }]; + let fold = fold_board(&spec, "home", &items, &cards, 0); + let snap = BoardSnapshot { + read: BoardRead { + board: Board { + key: 7, + repo_id: "home".into(), + state: BoardState::Open, + name: Some("B".into()), + spec: Some(spec), + spec_error: None, + sealed: false, + newest: BoardRevision { + id: "r".into(), + owner_id: "o".into(), + updated_at: 1, + }, + revisions: Vec::new(), + }, + cards: Vec::new(), + since: 0, + }, + items: BoardItemSet { + items, + ..BoardItemSet::default() + }, + fold: Some(fold), + now: 0, + }; + let col = snap.column(1); + assert_eq!( + col.iter().map(|c| c.id.as_str()).collect::>(), + ["b", "a"] + ); + assert_eq!(col[0].rank, "1"); + assert!(col[1].rank.starts_with('V')); + assert!(snap.placement("a").is_some() && snap.item("zz").is_none()); +} + +fn landed(document_id: &str, revision: u64, col: i64) -> LandedCard { + LandedCard { + document_id: document_id.into(), + revision, + card: CardDoc { + id: document_id.into(), + owner_id: encode_identifier(ALICE), + updated_at: 0, + item: encode_identifier(ITEM), + col: Some(col), + rank: None, + f: Some(r#"{"1":1}"#.into()), + state: CARD_ACTIVE, + }, + } +} + +/// §3.2: a member's own back-to-back writes must not undo each other. A write builds on the +/// card this client's last write landed while the fresh read lags behind it (it lacks the +/// document, or holds an older revision), and on the read once it caught up, another +/// member's newer card included. +#[test] +fn a_write_builds_on_its_last_landed_card_only_while_the_read_lags_behind_it() { + let item = encode_identifier(ITEM); + let read = |docs: Vec, own: Option<&str>| ItemCardDocs { + cards: docs + .iter() + .filter_map(|d| card_doc_of(d, Visibility::Public, None)) + .collect(), + own: own.map(str::to_string), + }; + let mut mine = card_doc(1, ALICE, 100, 2); + mine.revision = Some(3); + let mine_id = mine.id.clone(); + let l = landed(&mine_id, 4, 3); + // the read holds revision 3: older than the landed 4, so the landed card is the base + let (base, own, revision) = + card_base_of(Some(&l), &item, &read(vec![mine.clone()], Some(&mine_id))); + assert_eq!(base.and_then(|b| b.col), Some(3)); + assert_eq!((own.as_deref(), revision), (Some(mine_id.as_str()), 4)); + // a create whose read does not show it yet: the landed document is the one to replace + let (base, own, _) = card_base_of(Some(&l), &item, &read(Vec::new(), None)); + assert_eq!( + (base.and_then(|b| b.col), own.as_deref()), + (Some(3), Some(mine_id.as_str())) + ); + // caught up, and Bob wrote since: the read is the base, Bob's card included + mine.revision = Some(4); + let bob = card_doc(2, BOB, 200, 1); + let (base, own, revision) = card_base_of( + Some(&l), + &item, + &read(vec![mine, bob.clone()], Some(&mine_id)), + ); + assert_eq!(base.map(|b| b.id), Some(bob.id.clone())); + assert_eq!((own.as_deref(), revision), (Some(mine_id.as_str()), 4)); + // a read without revisions: behind while it holds other content than the landed card + let mut unrevised = card_doc(1, ALICE, 100, 2); + unrevised.revision = None; + let (base, ..) = card_base_of(Some(&l), &item, &read(vec![unrevised], Some(&mine_id))); + assert_eq!(base.and_then(|b| b.col), Some(3)); + let same = doc( + 1, + ALICE, + 100, + vec![ + ("repoId", FieldValue::identifier(REPO)), + ("board", FieldValue::integer(7)), + ("item", FieldValue::identifier(ITEM)), + ("col", FieldValue::integer(3)), + ("f", FieldValue::text(r#"{"1":1}"#)), + ("state", FieldValue::integer(0)), + ], + ); + let same = FetchedDocument { + revision: None, + ..same + }; + let (base, ..) = card_base_of(Some(&l), &item, &read(vec![same], Some(&mine_id))); + assert_eq!(base.map(|b| b.updated_at), Some(100)); + // nothing landed (another process, or a duplicate's re-read): the read's newest card, + // another device's own card included, never a card built before the conflict + let other_device = card_doc(3, ALICE, 300, 4); + let (base, own, revision) = card_base_of( + None, + &item, + &read(vec![bob, other_device.clone()], Some(&other_device.id)), + ); + assert_eq!(base.and_then(|b| b.col), Some(4)); + assert_eq!((own, revision), (Some(other_device.id), 1)); +} + +/// §5.6: an item's sidebar reads the boards of its repository and its owner's other public +/// repositories only; a private one's and a stranger's are never read. +#[test] +fn an_items_sidebar_reads_its_owners_public_repositories_only() { + let forge = crate::network::ForgeIds { + core: "core".into(), + collab: "collab".into(), + community: "community".into(), + meta: Some("meta".into()), + group: "group".into(), + superseded_in_group: Vec::new(), + group_owner: None, + }; + let owner = encode_identifier(ALICE); + let repo = RepoRef { + forge, + repo_id: encode_identifier(REPO), + owner_id: owner.clone(), + name: "forge".into(), + visibility: Visibility::Private, + }; + let repo_doc = |id: u8, who: [u8; 32], name: &str, visibility: &str| { + doc( + id, + who, + 1, + vec![ + ("name", FieldValue::text(name)), + ("visibility", FieldValue::text(visibility)), + ], + ) + }; + let homes = sidebar_homes_of( + &repo, + &[ + repo_doc(0x21, ALICE, "plan", "public"), + repo_doc(0x22, ALICE, "secret", "private"), + repo_doc(0x23, BOB, "theirs", "public"), + ], + ); + let names: Vec<&str> = homes.values().map(|r| r.name.as_str()).collect(); + assert_eq!(homes.len(), 2); + assert!(names.contains(&"forge") && names.contains(&"plan")); +} diff --git a/crates/forge-core/src/collab/mod.rs b/crates/forge-core/src/collab/mod.rs index 36d3bedd2..eb60215cc 100644 --- a/crates/forge-core/src/collab/mod.rs +++ b/crates/forge-core/src/collab/mod.rs @@ -6,6 +6,7 @@ //! stored numeric event kinds, and the text-length checks run before anything is signed. pub mod bans; +pub mod boards; pub mod long_body; pub mod moderation; pub mod parity; diff --git a/crates/forge-core/src/collab/v2.rs b/crates/forge-core/src/collab/v2.rs index a3d071eb1..05746daa8 100644 --- a/crates/forge-core/src/collab/v2.rs +++ b/crates/forge-core/src/collab/v2.rs @@ -2807,7 +2807,9 @@ pub fn gated_write(doc_type: &str, props: &BTreeMap) -> Opti } // `t_triageKinds` is a deny-list: an unknown kind (or none) is open to triage. DOC_EVENT => Some((kind.map_or(Role::Triage, members::event_code_needs), false)), - DOC_LABEL | DOC_MILESTONE => Some((Role::Triage, false)), + DOC_LABEL | DOC_MILESTONE | super::boards::DOC_CARD => Some((Role::Triage, false)), + // writers define boards, triage only places cards on them (`docs/design/boards.md` §5.1) + super::boards::DOC_BOARD => Some((Role::Writer, false)), _ => None, } } @@ -3268,6 +3270,7 @@ fn pr_list_reads<'c>( core: &'c LoadedContract, scope: &crate::scope::DocScope, limit: u32, + before: Option, ) -> [crate::platform::BatchRead<'c>; 4] { use crate::platform::{BatchBind, BatchRead}; let member = |role: Role| BatchRead { @@ -3282,7 +3285,8 @@ fn pr_list_reads<'c>( BatchRead { contract: collab, document_type: DOC_PATCH, - filters: scope.filters([]), + filters: scope + .filters(before.map(|b| QueryFilter::lte("$createdAt", FieldValue::uint64(b)))), order: vec![QueryOrder::desc("$createdAt")], limit, bind: None, @@ -3431,6 +3435,10 @@ pub struct Collab<'a> { /// A bot signer's `read` letter for the thread it replies on (§22.3), keyed by repository /// id ([`Self::use_read_letter`]): the members-only revisions it lists open with their keys. read_letter: std::sync::Mutex)>>, + /// The cards this `Collab`'s card writes landed, by `repoId:board:item`, with the revision + /// each wrote ([`Self::write_card`]): a later write of the same item applies its change over + /// one while a fresh read still holds an older revision (boards.md §3.2). + pub(super) landed_cards: std::sync::Mutex>, } /// A bot's post keys in one repository, by epoch. @@ -3492,6 +3500,7 @@ impl<'a> Collab<'a> { members_refs: std::sync::Mutex::default(), post_keys: std::sync::Mutex::default(), read_letter: std::sync::Mutex::default(), + landed_cards: std::sync::Mutex::default(), } } @@ -3522,6 +3531,7 @@ impl<'a> Collab<'a> { members_refs: std::sync::Mutex::default(), post_keys: std::sync::Mutex::default(), read_letter: std::sync::Mutex::default(), + landed_cards: std::sync::Mutex::default(), } } @@ -4385,7 +4395,7 @@ impl<'a> Collab<'a> { /// The keys anyone holds for a repository made public (`private-repos.md` §18.3): the epoch /// keys its owner published, which open what was written before them. `DocKeys::None(why)` /// for any other repository, or when none was published. - async fn published_keys(&self, repo: &RepoRef, why: Unopened) -> DocKeys { + pub(super) async fn published_keys(&self, repo: &RepoRef, why: Unopened) -> DocKeys { let converted = crate::repo::RepoService::reader(self.client) .conversion(repo) .await @@ -6036,11 +6046,24 @@ impl<'a> Collab<'a> { /// [`Self::list_patch_views`] with, for each members-only PR of the page this reader cannot /// open, its placeholder and its log (transitions and events: open, merged or closed, and /// what moderation needs), so a list can filter and order it like the others. - #[allow(clippy::too_many_lines)] // the reads, then one fold per row pub async fn list_patch_views_read( &self, repo: &RepoRef, limit: u32, + ) -> Result<(Listed<(PatchView, Approvals)>, Vec)> { + self.list_patch_views_before(repo, limit, None).await + } + + /// [`Self::list_patch_views_read`] of the pull requests created at or before `before` (ms; + /// `None`: the newest): one page of a newest-first walk through every pull request, as a + /// board's source reads them (`collab::boards`). A page that repeats rows of the previous + /// one's last time is the caller's to dedupe. + #[allow(clippy::too_many_lines)] // the reads, then one fold per row + pub async fn list_patch_views_before( + &self, + repo: &RepoRef, + limit: u32, + before: Option, ) -> Result<(Listed<(PatchView, Approvals)>, Vec)> { let forge = repo.forge(); self.client @@ -6051,7 +6074,7 @@ impl<'a> Collab<'a> { let community = self.community_contract(repo).await?; let scope = repo.scope()?; let limit = page_limit(limit); - let reads = pr_list_reads(&collab, &core, &scope, limit); + let reads = pr_list_reads(&collab, &core, &scope, limit, before); let [feed_a, feed_b, feed_c] = Self::feed_specs(&collab, &community, &scope); let [refs_a, refs_b, refs_c] = crate::refs::GitState::specs(&core, &scope); let history = [feed_a, feed_b, feed_c, refs_a, refs_b, refs_c]; diff --git a/crates/forge-core/src/keyring.rs b/crates/forge-core/src/keyring.rs index 622e4c0f0..cc0f036c4 100644 --- a/crates/forge-core/src/keyring.rs +++ b/crates/forge-core/src/keyring.rs @@ -1203,6 +1203,16 @@ impl Keyring { } } + /// [`crate::private::board::open`] (private-repos.md §4.6) for a stored `board` or `card` + /// under this reader's keys, anchors and members. + #[must_use] + pub fn open_board( + &self, + d: &crate::private::board::StoredBoardDoc, + ) -> crate::private::board::Opened { + crate::private::board::open(&self.ctx, d) + } + /// Whether an artifact sealed under `epoch` and first recorded at block height `height` was /// uploaded after the late-content cut-off for that epoch, whoever uploaded it (§8.2): /// `stated(next(e)) + GRACE_BLOCKS`, or at any height under a burned epoch. A named sealed diff --git a/crates/forge-core/src/layout.rs b/crates/forge-core/src/layout.rs index eab615e57..5e8e6b747 100644 --- a/crates/forge-core/src/layout.rs +++ b/crates/forge-core/src/layout.rs @@ -7,7 +7,8 @@ //! //! DESIGN rev 4.1 D44 adds a fourth contract, forge-meta, registered last: `repoKey`, `ban`, //! `label`, `topic`, `packMirror`, `profile` and `follow` ([`META_TYPES`]) move there, and -//! `vaultEntry` (UPDATE-2, the passkey vault) exists there only. The +//! `vaultEntry` (UPDATE-2, the passkey vault), `board` and `card` (UPDATE-3, boards) exist there +//! only ([`META_ONLY_TYPES`]). The //! deployment record says which layout a network has (`v2.forgeMeta` present, //! [`ForgeIds::meta`]), so one build serves sakura's three-contract set and four-contract sets: //! [`ForgeIds::contract_of`] is the layout-aware map, [`ForgeContract::of`] the three-contract @@ -87,10 +88,10 @@ pub const COMMUNITY_TYPES: [&str; 12] = [ /// The types forge-meta holds on a four-contract set (D44). On a three-contract set they stay /// in [`CORE_TYPES`] (`label`, `topic`, `packMirror`), [`COLLAB_TYPES`] (`repoKey`, `ban`) and /// [`COMMUNITY_TYPES`] (`profile`, `follow`). None of them is read by a rule, total or derived -/// index of its old contract, so the move changes no consensus rule. `vaultEntry` (UPDATE-2) is -/// the exception: `build.py` builds it with the four-contract layout only, so it has no -/// three-contract home and [`ForgeContract::of`] knows no contract for it. -pub const META_TYPES: [&str; 8] = [ +/// index of its old contract, so the move changes no consensus rule. [`META_ONLY_TYPES`] are the +/// exception: `build.py` builds them with the four-contract layout only, so they have no +/// three-contract home and [`ForgeContract::of`] knows no contract for them. +pub const META_TYPES: [&str; 10] = [ "repoKey", "ban", "label", @@ -99,8 +100,15 @@ pub const META_TYPES: [&str; 8] = [ "profile", "follow", "vaultEntry", + "board", + "card", ]; +/// The [`META_TYPES`] no three-contract set has: `vaultEntry` (UPDATE-2, the passkey vault) and +/// `board` and `card` (UPDATE-3, `docs/design/boards.md` §3). On a network without forge-meta +/// [`ForgeIds::contract_of`] answers `None` for them. +pub const META_ONLY_TYPES: [&str; 3] = ["vaultEntry", "board", "card"]; + /// The listed types a contract build may leave out: RC2's fused star (C1, a `build.py` flag) /// drops `starBeat`, whose count the star's own `byWeek` index takes over. Clients read the /// shape from the loaded contract (`Collab::fused_star`), so both builds work. `packMirror` and @@ -419,8 +427,18 @@ mod tests { assert_eq!(four.contract_id_of(t), Some("META"), "{t}"); assert_eq!(four.home(t), "META", "{t}"); assert_ne!(three.contract_id_of(t), Some("META"), "{t}"); - // (vaultEntry, UPDATE-2, is a four-contract type: no home in the three-contract set) - assert_eq!(three.contract_id_of(t).is_some(), t != "vaultEntry", "{t}"); + // (vaultEntry, board and card are four-contract types: no home in the three-contract set) + assert_eq!( + three.contract_id_of(t).is_some(), + !META_ONLY_TYPES.contains(&t), + "{t}" + ); + } + for t in META_ONLY_TYPES { + assert!(META_TYPES.contains(&t), "{t}"); + assert_eq!(ForgeContract::of(t), None, "{t}"); + assert_eq!(three.contract_of(t), None, "{t}"); + assert_eq!(four.contract_of(t), Some(ForgeContract::Meta), "{t}"); } for (t, old) in [ ("repoKey", "COLLAB"), diff --git a/crates/forge-core/src/members.rs b/crates/forge-core/src/members.rs index f5dd885de..0ce3f39ec 100644 --- a/crates/forge-core/src/members.rs +++ b/crates/forge-core/src/members.rs @@ -57,12 +57,15 @@ pub const WRITER_ROLE: &str = "role"; /// The property a role-gated write claims its signer's role in (RC2 member roles): on /// `refUpdate`, `packManifest`, `chunk` and `checkRun` (always 1), and `label`, `milestone`, -/// `transition` and `event` (1 or 2). The contract's writer leaf proves it equals the signer's -/// `writer.role`; the maintainer, author and runner operands prove nothing about it. +/// `transition` and `event` (1 or 2); forge-meta's `board` (1 only: writers define boards, +/// triage does not) and `card` (1 or 2: triage places cards; UPDATE-3, +/// `docs/design/boards.md` §3, parity: forge-web `lib/rules/roles.ts`). The contract's writer +/// leaf proves it equals the signer's `writer.role`; the maintainer, author and runner +/// operands prove nothing about it. pub const CLAIMED_ROLE: &str = "r"; /// The document types that carry [`CLAIMED_ROLE`]. -pub const ROLE_GATED_TYPES: [&str; 8] = [ +pub const ROLE_GATED_TYPES: [&str; 10] = [ "refUpdate", "packManifest", "chunk", @@ -71,6 +74,8 @@ pub const ROLE_GATED_TYPES: [&str; 8] = [ "milestone", "transition", "event", + "board", + "card", ]; /// The `r` a role-gated write claims ([`CLAIMED_ROLE`]): 1 when the signer writes as a diff --git a/crates/forge-core/src/private/board.rs b/crates/forge-core/src/private/board.rs new file mode 100644 index 000000000..6b7f2ecc2 --- /dev/null +++ b/crates/forge-core/src/private/board.rs @@ -0,0 +1,383 @@ +//! Sealed boards and cards of a private repository (`docs/security/private-repos.md` §4.6, +//! `docs/design/boards.md` §3.3): a `board`'s `name` and `spec`, and a `card`'s `col`, `rank` +//! and `f`, sealed together into `enc` v0x01 under the repository's current epoch with the §4.4 +//! framing (`docType` `board` bound to `u32(key)`, `card` bound to `u32(board) ‖ item`), so a +//! sealed payload cannot be moved to another board or item. +//! +//! The `sealed_board__*` vectors (`tools/private-repos-vectors/boards.py`) hold this module byte +//! for byte against forge-web's `lib/private/board.ts` (this module's `conformance` tests). + +use aes_gcm::aead::{Aead, KeyInit, Payload}; +use aes_gcm::{Aes256Gcm, Nonce}; +use serde::{Deserialize, Serialize}; + +use super::doc::{build_ad, OpenContext, Unreadable, MIN_V1, V1}; +use super::keys::EpochKeys; +use super::tlv::{pad_record_in, push_record}; +use super::PrivateError; +use crate::rules::boards::{is_board_name, is_explicit_rank, SPEC_MAX_BYTES}; + +/// The vector case these documents' vectors carry. +pub const VECTOR_CASE: &str = "sealed_board"; + +/// forge-meta `board.enc` `maxItems`. +pub const BOARD_MAX_ENC: usize = 5120; +/// forge-meta `card.enc` `maxItems`. +pub const CARD_MAX_ENC: usize = 2560; +/// The largest TLV a board seals: its `enc` cap less the v0x01 framing (29 bytes). +pub const BOARD_MAX_PLAINTEXT: usize = BOARD_MAX_ENC - MIN_V1; +/// The largest TLV a card seals. +pub const CARD_MAX_PLAINTEXT: usize = CARD_MAX_ENC - MIN_V1; + +const TAG_NAME: u8 = 32; +const TAG_SPEC: u8 = 33; +const TAG_COL: u8 = 34; +const TAG_RANK: u8 = 35; +const TAG_FIELDS: u8 = 36; +const TAG_PADDING: u8 = 64; +/// A sealed TLV is padded to a multiple of this many bytes (a release's bucket, §16.2). +const PAD_BUCKET: usize = 32; +/// `card.f`'s cap (the plaintext schema's). +const FIELDS_MAX_BYTES: usize = 2048; + +/// The plaintext identity a sealed board or card is bound to (§4.4 `bind`). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Bind { + /// A board: its key (1 … 2³²−1). + Board { + /// `board.key`. + key: u32, + }, + /// A card: its board's key and its item's `$id`. + Card { + /// `card.board`. + board: u32, + /// `card.item` (32 bytes). + item: [u8; 32], + }, +} + +impl Bind { + /// The `docType` of the AD. + #[must_use] + pub fn type_name(&self) -> &'static str { + match self { + Self::Board { .. } => "board", + Self::Card { .. } => "card", + } + } + + /// The plaintext content fields of the type, which a sealed document may not carry + /// (`noPlain`): a board's `name` and `spec`, a card's `col`, `rank` and `f`. + #[must_use] + pub fn plaintext_fields(&self) -> &'static [&'static str] { + match self { + Self::Board { .. } => &["name", "spec"], + Self::Card { .. } => &["col", "rank", "f"], + } + } + + /// `u32(key)` or `u32(board) ‖ item`; `None` for a key of 0 (no board has it). + fn bytes(&self) -> Option> { + match self { + Self::Board { key } => (*key != 0).then(|| key.to_be_bytes().to_vec()), + Self::Card { board, item } => (*board != 0).then(|| { + let mut b = board.to_be_bytes().to_vec(); + b.extend_from_slice(item); + b + }), + } + } +} + +/// A board's sealed fields: its name and its definition (the spec JSON, judged by the board +/// rules, not here). +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct BoardFields { + /// TLV 32. + pub name: String, + /// TLV 33. + pub spec: String, +} + +/// A card's sealed fields, each absent when the card has none. +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct CardFields { + /// TLV 34: the column id. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub col: Option, + /// TLV 35: the rank. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub rank: Option, + /// TLV 36: the field values' JSON (`card.f`). + #[serde(default, skip_serializing_if = "Option::is_none")] + pub f: Option, +} + +/// What a board or a card seals. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum Content { + /// A board's. + Board(BoardFields), + /// A card's. + Card(CardFields), +} + +/// Whether `f` may be sealed as a board (a reader accepts it). +fn board_ok(f: &BoardFields) -> bool { + is_board_name(&f.name) && (1..=SPEC_MAX_BYTES).contains(&f.spec.len()) +} + +/// Whether `f` may be sealed as a card. +fn card_ok(f: &CardFields) -> bool { + f.rank.as_deref().is_none_or(is_explicit_rank) + && f.f + .as_deref() + .is_none_or(|j| (1..=FIELDS_MAX_BYTES).contains(&j.len())) +} + +/// The TLV records of `c`, ascending, without padding (§4.6); an empty card is no records. +fn encode(c: &Content) -> Vec { + let mut out = Vec::new(); + match c { + Content::Board(f) => { + push_record(&mut out, TAG_NAME, f.name.as_bytes()); + push_record(&mut out, TAG_SPEC, f.spec.as_bytes()); + } + Content::Card(f) => { + if let Some(col) = f.col { + push_record(&mut out, TAG_COL, &[col]); + } + if let Some(r) = &f.rank { + push_record(&mut out, TAG_RANK, r.as_bytes()); + } + if let Some(j) = &f.f { + push_record(&mut out, TAG_FIELDS, j.as_bytes()); + } + } + } + out +} + +/// Parse a board's (`bind` a board) or a card's TLV (§4.6): records strictly ascending, none +/// repeated; tags 1–63 other than the kind's own are malformed, 64–255 skipped (64 pads); every +/// value valid and within its cap; a zero-length text record counts as absent; a board needs +/// its name and spec. `None` is `Malformed`. +#[must_use] +pub fn parse(bind: &Bind, pt: &[u8]) -> Option { + let board = matches!(bind, Bind::Board { .. }); + let (mut name, mut spec, mut card) = (None, None, CardFields::default()); + let mut last = 0u8; + let mut rest = pt; + while !rest.is_empty() { + let (&tag, tail) = rest.split_first()?; + let len = usize::from(u16::from_be_bytes(tail.get(..2)?.try_into().ok()?)); + let v = tail.get(2..2 + len)?; + rest = &tail[2 + len..]; + if tag <= last { + return None; + } + last = tag; + if tag >= TAG_PADDING { + continue; + } + let text = || -> Option> { + let s = std::str::from_utf8(v).ok()?; + Some((!s.is_empty()).then(|| s.to_string())) + }; + match (board, tag) { + (true, TAG_NAME) => name = text()?, + (true, TAG_SPEC) => spec = text()?, + (false, TAG_COL) => { + let [c] = v else { return None }; + card.col = Some(*c); + } + (false, TAG_RANK) => card.rank = text()?, + (false, TAG_FIELDS) => card.f = text()?, + _ => return None, + } + } + if board { + let f = BoardFields { + name: name?, + spec: spec?, + }; + return board_ok(&f).then_some(Content::Board(f)); + } + card_ok(&card).then_some(Content::Card(card)) +} + +/// The §4.4 AD of a board or card under `keys` (the epoch it is sealed under) for `owner`. +/// `Malformed` for a key of 0. +pub fn ad(keys: &EpochKeys, owner: &[u8; 32], bind: &Bind) -> Result, PrivateError> { + let b = bind.bytes().ok_or(PrivateError::Malformed)?; + Ok(build_ad( + keys.repo_id(), + owner, + keys.epoch(), + V1, + bind.type_name(), + &b, + )) +} + +/// The padded TLV a writer seals for `c` as `bind`, or `Malformed` where a reader would refuse +/// it (or the content is not the bind's kind). +pub fn writer_tlv(bind: &Bind, c: &Content) -> Result, PrivateError> { + let (ok, cap) = match (bind, c) { + (Bind::Board { .. }, Content::Board(f)) => (board_ok(f), BOARD_MAX_PLAINTEXT), + (Bind::Card { .. }, Content::Card(f)) => (card_ok(f), CARD_MAX_PLAINTEXT), + _ => (false, 0), + }; + if !ok { + return Err(PrivateError::Malformed); + } + let mut pt = encode(c); + // never above the cap: every field is bounded well below it (§4.6) + if pt.len() > cap { + return Err(PrivateError::TooLarge(bind.type_name(), cap)); + } + pt.extend(pad_record_in(pt.len(), cap, PAD_BUCKET)); + // a writer never emits what a reader refuses + if parse(bind, &pt).as_ref() != Some(c) { + return Err(PrivateError::Malformed); + } + Ok(pt) +} + +/// A sealed board or card and the intermediate values the vectors pin. +pub struct Sealed { + /// The associated data (§4.4). + pub ad: Vec, + /// The padded TLV plaintext (zeroized on drop). + pub tlv: zeroize::Zeroizing>, + /// `enc`. + pub enc: Vec, +} + +/// Seal `c` as `owner`'s `bind` document under `keys` (the repository's current write epoch) +/// with a hedged random nonce (§3.6): the `enc` of `{repoId, key | (board, item), state, +/// epoch: keys.epoch(), enc, r}`, with no plaintext name, spec, col, rank or f. +pub fn seal( + keys: &EpochKeys, + owner: &[u8; 32], + bind: &Bind, + c: &Content, +) -> Result, PrivateError> { + let rnd = super::keys::rnd32()?; + Ok(seal_inner(keys, owner, bind, c, |ad, tlv| { + keys.hedged_nonce(&rnd, ad, tlv) + })? + .enc) +} + +/// [`seal`] with a fixed nonce: the conformance vectors only. +#[cfg(any(test, feature = "vectors"))] +pub fn seal_with_nonce( + keys: &EpochKeys, + owner: &[u8; 32], + bind: &Bind, + c: &Content, + nonce: [u8; 12], +) -> Result { + seal_inner(keys, owner, bind, c, |_, _| nonce) +} + +fn seal_inner( + keys: &EpochKeys, + owner: &[u8; 32], + bind: &Bind, + c: &Content, + nonce: impl FnOnce(&[u8], &[u8]) -> [u8; 12], +) -> Result { + let tlv = zeroize::Zeroizing::new(writer_tlv(bind, c)?); + let ad = ad(keys, owner, bind)?; + let nonce = nonce(&ad, &tlv); + let ct = Aes256Gcm::new(keys.doc_key().into()) + .encrypt( + Nonce::from_slice(&nonce), + Payload { + msg: &tlv, + aad: &ad, + }, + ) + .map_err(|_| PrivateError::Malformed)?; + let mut enc = vec![V1]; + enc.extend_from_slice(&nonce); + enc.extend_from_slice(&ct); + Ok(Sealed { ad, tlv, enc }) +} + +/// A stored board or card, as [`open`] reads it. +#[derive(Debug, Clone)] +pub struct StoredBoardDoc { + /// Its immutable keys. + pub bind: Bind, + /// `$ownerId`. + pub owner_id: [u8; 32], + /// `epoch`, when a u32. + pub epoch: Option, + /// `enc`. + pub enc: Option>, + /// Whether it also carries a plaintext content field (a board's `name` / `spec`; a card's + /// `col` / `rank` / `f`): malformed. + pub plaintext: bool, +} + +/// The result of [`open`], as `doc::Opened` is for the collab types. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum Opened { + /// The decoded fields. + Readable(Content), + /// Well-framed but not readable by this reader. + Unreadable(Unreadable), + /// A document no honest writer produces; skipped. + Malformed, +} + +/// Open a sealed board or card (§4.6, in order): the key-independent checks (an `enc`, a u32 +/// `epoch`, no plaintext content, at least 29 bytes), the framing (a version other than 0x01, a +/// later client's members-only board, is `UnknownVersion`, never malformed), the epoch and key, +/// AES-GCM, the TLV, then the burned clause of the late-content rule. Both types are +/// member-gated at consensus on every replace (boards.md §3), so the height part of §8.2 does +/// not apply, as for a member `event`. +#[must_use] +pub fn open(ctx: &OpenContext, d: &StoredBoardDoc) -> Opened { + let (Some(enc), Some(epoch)) = (d.enc.as_deref(), d.epoch) else { + return Opened::Malformed; + }; + if d.plaintext || enc.len() < MIN_V1 { + return Opened::Malformed; + } + if enc[0] != V1 { + return Opened::Unreadable(Unreadable::UnknownVersion); + } + if !ctx.anchors.contains_key(&epoch) { + return Opened::Unreadable(Unreadable::NoEpoch); + } + let Some(keys) = ctx.keys.get(&epoch) else { + return Opened::Unreadable(Unreadable::NoKey); + }; + let Ok(ad) = ad(keys, &d.owner_id, &d.bind) else { + return Opened::Malformed; + }; + let (nonce, ct) = enc[1..].split_at(12); + let Ok(pt) = Aes256Gcm::new(keys.doc_key().into()) + .decrypt(Nonce::from_slice(nonce), Payload { msg: ct, aad: &ad }) + else { + return Opened::Unreadable(Unreadable::BadTag); + }; + let pt = zeroize::Zeroizing::new(pt); + let Some(c) = parse(&d.bind, &pt) else { + return Opened::Malformed; + }; + if ctx.burned.contains(&epoch) && !ctx.members.contains(&d.owner_id) { + return Opened::Unreadable(Unreadable::Late); + } + Opened::Readable(c) +} + +#[cfg(test)] +mod conformance; diff --git a/crates/forge-core/src/private/board/conformance.rs b/crates/forge-core/src/private/board/conformance.rs new file mode 100644 index 000000000..0cccaad79 --- /dev/null +++ b/crates/forge-core/src/private/board/conformance.rs @@ -0,0 +1,260 @@ +//! The `sealed_board__*` vectors (`tools/private-repos-vectors/boards.py`, an independent +//! Python reference over `private-repos.md` §4.6), run byte for byte, as forge-web's +//! `lib/private/board.conformance.test.ts` runs them. Unknown input keys are refused. + +use std::path::PathBuf; + +use serde::Deserialize; +use serde_json::{json, Value}; + +use super::{ + open, parse, seal, seal_with_nonce, Bind, BoardFields, CardFields, Content, Opened, + StoredBoardDoc, VECTOR_CASE, +}; +use crate::private::conformance::{h32, key, nonce12, open_context, OpenCtxIn, Vector}; +use crate::private::{doc, EpochKeys, PrivateError}; + +#[derive(Deserialize)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +struct DocIn { + #[serde(rename = "type")] + kind: String, + #[serde(default)] + key: Option, + #[serde(default)] + board: Option, + #[serde(default)] + item: Option, + #[serde(default)] + owner_id: Option, + #[serde(default)] + epoch: Option, + #[serde(default)] + plaintext: Option, + #[serde(default)] + enc: Option, +} + +impl DocIn { + /// The bind, or `None` for a key or board out of u32 range (malformed input). + fn bind(&self) -> Option { + let u32_of = |v: Option| v.and_then(|n| u32::try_from(n).ok()); + Some(match self.kind.as_str() { + "board" => Bind::Board { + key: u32_of(self.key)?, + }, + "card" => Bind::Card { + board: u32_of(self.board)?, + item: h32(self.item.as_deref()?), + }, + other => panic!("unknown doc type {other}"), + }) + } +} + +/// A card's fields as the vectors give them: `col` may be out of the byte's range. +#[derive(Deserialize)] +#[serde(deny_unknown_fields)] +struct FieldsIn { + #[serde(default)] + name: Option, + #[serde(default)] + spec: Option, + #[serde(default)] + col: Option, + #[serde(default)] + rank: Option, + #[serde(default)] + f: Option, +} + +#[derive(Deserialize)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +struct In { + op: String, + repo_id: String, + #[serde(default)] + key: Option, + #[serde(default)] + epoch: Option, + #[serde(default)] + owner_id: Option, + #[serde(default)] + nonce: Option, + #[serde(default)] + context: Option, + doc: DocIn, + #[serde(default)] + fields: Option, +} + +fn content_of(bind: &Bind, f: FieldsIn) -> Option { + Some(match bind { + Bind::Board { .. } => Content::Board(BoardFields { + name: f.name.unwrap_or_default(), + spec: f.spec.unwrap_or_default(), + }), + Bind::Card { .. } => Content::Card(CardFields { + col: f.col.map(u8::try_from).transpose().ok()?, + rank: f.rank, + f: f.f, + }), + }) +} + +fn content_json(c: &Content) -> Value { + match c { + Content::Board(f) => serde_json::to_value(f).unwrap(), + Content::Card(f) => serde_json::to_value(f).unwrap(), + } +} + +#[allow(clippy::many_single_char_names)] // the vector's input, keys, bind, content, doc +fn run(v: &Vector) -> Value { + let i: In = serde_json::from_value(v.input.clone()) + .unwrap_or_else(|e| panic!("vector `{}`: input: {e}", v.name)); + let repo_id = h32(&i.repo_id); + if i.op == "seal" { + let keys = EpochKeys::derive(&repo_id, i.epoch.unwrap(), &key(i.key.as_deref().unwrap())); + let owner = h32(i.owner_id.as_deref().unwrap()); + let bind = i.doc.bind().unwrap(); + // a value no field holds (a column of 256) is refused as the writer refuses it + let Some(c) = content_of(&bind, i.fields.unwrap()) else { + return json!({ "error": "malformed" }); + }; + return match seal_with_nonce( + &keys, + &owner, + &bind, + &c, + nonce12(i.nonce.as_deref().unwrap()), + ) { + Ok(s) => { + // what the writer seals is what a reader accepts + assert_eq!(parse(&bind, &s.tlv).as_ref(), Some(&c), "{}", v.name); + json!({ + "ad": hex::encode(&s.ad), + "tlv": hex::encode(&*s.tlv), + "enc": hex::encode(&s.enc), + }) + } + Err(PrivateError::Malformed) => json!({ "error": "malformed" }), + Err(e) => panic!("vector `{}`: {e}", v.name), + }; + } + assert_eq!(i.op, "open", "{}", v.name); + let c: OpenCtxIn = serde_json::from_value(i.context.unwrap()).unwrap(); + let ctx = open_context(&repo_id, &c); + let d = &i.doc; + let stored = StoredBoardDoc { + bind: d.bind().unwrap(), + owner_id: h32(d.owner_id.as_deref().unwrap()), + epoch: d.epoch.and_then(|e| u32::try_from(e).ok()), + enc: d.enc.as_deref().map(|e| hex::decode(e).unwrap()), + plaintext: d.plaintext == Some(true), + }; + match open(&ctx, &stored) { + Opened::Readable(c) => json!({ "status": "readable", "fields": content_json(&c) }), + Opened::Unreadable(r) => json!({ "status": "unreadable", "reason": r }), + Opened::Malformed => json!({ "status": "malformed" }), + } +} + +/// THE PARITY PROOF for sealed boards and cards: every `sealed_board__*` vector. +#[test] +fn sealed_board_vectors() { + let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../forge-contracts/vectors"); + let mut files: Vec = std::fs::read_dir(&dir) + .expect("read vectors dir") + .map(|e| e.unwrap().path()) + .filter(|p| { + p.extension().is_some_and(|x| x == "json") + && p.file_name() + .and_then(|n| n.to_str()) + .is_some_and(|n| n.starts_with("sealed_board__")) + }) + .collect(); + files.sort(); + let (mut seals, mut opens) = (0, 0); + for path in &files { + let v: Vector = serde_json::from_slice(&std::fs::read(path).unwrap()) + .unwrap_or_else(|e| panic!("parse {}: {e}", path.display())); + assert_eq!(v.case, VECTOR_CASE, "{}", path.display()); + if v.input["op"] == "seal" { + seals += 1; + } else { + opens += 1; + } + assert_eq!(run(&v), v.expected, "vector `{}`", v.name); + } + assert!( + seals >= 15 && opens >= 20, + "ran {seals} seal and {opens} open vectors" + ); + println!("sealed_board: {} vectors green", seals + opens); +} + +/// A hedged seal never repeats, and both kinds open to what was sealed. +#[test] +fn a_hedged_seal_round_trips_and_never_repeats() { + let keys = EpochKeys::derive( + &[0x11; 32], + 3, + &crate::private::EpochKey::from_bytes([5; 32]), + ); + let owner = [0x22; 32]; + let ctx = doc::OpenContext { + keys: [(3, keys.clone())].into(), + anchors: [( + 3, + doc::AnchorRef { + id: [0; 32], + height: 1, + stated_height: 1, + }, + )] + .into(), + ..doc::OpenContext::default() + }; + let board = Content::Board(BoardFields { + name: "Roadmap".into(), + spec: r#"{"v":1,"columns":[{"id":1,"name":"Todo"}]}"#.into(), + }); + let bind = Bind::Board { key: 9 }; + let a = seal(&keys, &owner, &bind, &board).unwrap(); + let b = seal(&keys, &owner, &bind, &board).unwrap(); + assert_ne!(a, b); + let stored = |bind, enc| StoredBoardDoc { + bind, + owner_id: owner, + epoch: Some(3), + enc: Some(enc), + plaintext: false, + }; + assert_eq!( + open(&ctx, &stored(bind, a)), + Opened::Readable(board.clone()) + ); + let card = Content::Card(CardFields { + col: Some(1), + rank: Some("Vx".into()), + f: Some(r#"{"1":2}"#.into()), + }); + let bind = Bind::Card { + board: 9, + item: [0x44; 32], + }; + let c = seal(&keys, &owner, &bind, &card).unwrap(); + assert_eq!(open(&ctx, &stored(bind, c.clone())), Opened::Readable(card)); + // the same card bound to another item does not open + let moved = Bind::Card { + board: 9, + item: [0x45; 32], + }; + assert_eq!( + open(&ctx, &stored(moved, c)), + Opened::Unreadable(doc::Unreadable::BadTag) + ); + // a board's content is refused as a card's + assert!(seal(&keys, &owner, &bind, &board).is_err()); +} diff --git a/crates/forge-core/src/private/doc.rs b/crates/forge-core/src/private/doc.rs index e70a978b5..8df253c73 100644 --- a/crates/forge-core/src/private/doc.rs +++ b/crates/forge-core/src/private/doc.rs @@ -185,17 +185,14 @@ impl DocHeader { } fn ad_with(&self, repo_id: &[u8; 32], epoch: u32, version: u8, bind: &[u8]) -> Vec { - let t = self.kind.type_name().as_bytes(); - let mut ad = Vec::with_capacity(AD_DOMAIN.len() + 1 + 64 + 4 + t.len() + 1 + bind.len()); - ad.extend_from_slice(AD_DOMAIN); - ad.push(version); - ad.extend_from_slice(repo_id); - ad.extend_from_slice(&self.owner_id); - ad.extend_from_slice(&epoch.to_be_bytes()); - ad.extend_from_slice(t); - ad.push(0); - ad.extend_from_slice(bind); - ad + build_ad( + repo_id, + &self.owner_id, + epoch, + version, + self.kind.type_name(), + bind, + ) } fn version(&self) -> u8 { @@ -207,6 +204,30 @@ impl DocHeader { } } +/// The associated data of §4.4: `"dash-forge/v2/doc" ‖ 0x00 ‖ version ‖ repoId ‖ $ownerId ‖ +/// u32(epoch) ‖ docType ‖ 0x00 ‖ bind`. Also forge-meta's sealed boards and cards +/// ([`super::board::ad`]), whose types are not [`DocKind`]s. +pub(crate) fn build_ad( + repo_id: &[u8; 32], + owner_id: &[u8; 32], + epoch: u32, + version: u8, + doc_type: &str, + bind: &[u8], +) -> Vec { + let t = doc_type.as_bytes(); + let mut ad = Vec::with_capacity(AD_DOMAIN.len() + 1 + 64 + 4 + t.len() + 1 + bind.len()); + ad.extend_from_slice(AD_DOMAIN); + ad.push(version); + ad.extend_from_slice(repo_id); + ad.extend_from_slice(owner_id); + ad.extend_from_slice(&epoch.to_be_bytes()); + ad.extend_from_slice(t); + ad.push(0); + ad.extend_from_slice(bind); + ad +} + /// The ref-name hash check of §4.5 (H3), after decryption: each hash field present on the /// document must equal the keyed hash of the name inside `enc`. A members (v0x03) patch may /// instead carry the public `sha256(name)` of a public branch (its base or source, §4.4 of the diff --git a/crates/forge-core/src/private/mod.rs b/crates/forge-core/src/private/mod.rs index 502f1c63e..d4f2ebd22 100644 --- a/crates/forge-core/src/private/mod.rs +++ b/crates/forge-core/src/private/mod.rs @@ -18,6 +18,7 @@ //! * [`wrap`]: the 47-byte `repoKey` wrap plaintext (§5.1); //! * [`release`]: sealed releases: the keyed `tagName`, the TLV, the open, the kind-4 asset //! manifest and the reader's fold over a tag's revisions (§16); +//! * [`board`]: a private repository's sealed boards and cards (§4.6, UPDATE-3); //! * [`bundle`]: make-public bundles (kind 7), and [`convert`]: what readers derive about a //! repository made public, and the epoch keys its owner published (§18); //! * [`epoch`]: anchors, the current epoch, the chain walk, alerts and the repair check, as one @@ -43,6 +44,7 @@ compile_error!("the `vectors` feature (deterministic nonces and file ids) is for mod access_conformance; pub mod access_notice; pub mod blind; +pub mod board; pub mod bot_post; pub mod branch_key; pub mod bundle; diff --git a/crates/forge-core/src/private/tlv.rs b/crates/forge-core/src/private/tlv.rs index 295c84cf2..e6cc8b41c 100644 --- a/crates/forge-core/src/private/tlv.rs +++ b/crates/forge-core/src/private/tlv.rs @@ -507,7 +507,7 @@ pub fn letter_kind(kind: DocKind) -> bool { /// One record `tag ‖ u16(len) ‖ value`. A value longer than u16 cannot be represented; /// truncating the length would corrupt the framing, so it is written as-is and refused by the /// parse every writer runs on its own output. -fn push_record(out: &mut Vec, tag: u8, v: &[u8]) { +pub(crate) fn push_record(out: &mut Vec, tag: u8, v: &[u8]) { let len = u16::try_from(v.len()).unwrap_or(u16::MAX); out.push(tag); out.extend_from_slice(&len.to_be_bytes()); @@ -521,10 +521,17 @@ fn push_record(out: &mut Vec, tag: u8, v: &[u8]) { /// bucket. #[must_use] pub fn pad_record(n: usize, max: usize) -> Vec { + pad_record_in(n, max, PAD_BUCKET) +} + +/// [`pad_record`] to a multiple of `bucket` (a sealed release's and board's is 32, §16.2, +/// §4.6). +#[must_use] +pub(crate) fn pad_record_in(n: usize, max: usize, bucket: usize) -> Vec { if n + 3 > max { return Vec::new(); } - let fill = ((PAD_BUCKET - (n + 3) % PAD_BUCKET) % PAD_BUCKET).min(max - 3 - n); + let fill = ((bucket - (n + 3) % bucket) % bucket).min(max - 3 - n); let mut out = Vec::with_capacity(3 + fill); push_record(&mut out, PAD, &vec![0; fill]); out diff --git a/crates/forge-core/src/rules.rs b/crates/forge-core/src/rules.rs index baf70f3d6..4168f5025 100644 --- a/crates/forge-core/src/rules.rs +++ b/crates/forge-core/src/rules.rs @@ -50,6 +50,7 @@ pub mod agent_request; pub mod asset_name; pub mod aud; pub mod bans; +pub mod boards; pub mod ci_rerun; pub mod codeowners; pub mod embargo; @@ -3871,7 +3872,8 @@ mod tests { let v: Vector = serde_json::from_slice(&bytes) .unwrap_or_else(|e| panic!("parse {}: {e}", path.display())); // the private-repository and mixed-visibility envelope vectors run in - // `private::conformance`, the environment snapshots in `env::conformance` + // `private::conformance`, the environment snapshots in `env::conformance`, the + // boards' (`board_*`) in `boards::tests::board_vectors` if crate::private::conformance::CRYPTO_CASE_PREFIXES .iter() .any(|p| v.case.starts_with(p)) @@ -3880,10 +3882,14 @@ mod tests { || v.case == crate::private::access_notice::VECTOR_CASE || v.case == crate::private::bot_post::VECTOR_CASE || v.case == crate::rules::push_grant::VECTOR_CASE + || v.case.starts_with(crate::rules::boards::VECTOR_CASE_PREFIX) || crate::members_git::conformance::CASES.contains(&v.case.as_str()) || v.case == crate::private::branch_key::conformance::CASE || v.case == crate::private::members_check::CASE || v.case == "seal_off_marker" + // a private repository's sealed boards and cards: `private::board`'s own + // harness runs them (as forge-web `lib/private/board.conformance.test.ts` does) + || v.case == crate::private::board::VECTOR_CASE { continue; } diff --git a/crates/forge-core/src/rules/boards.rs b/crates/forge-core/src/rules/boards.rs new file mode 100644 index 000000000..84a8f32c7 --- /dev/null +++ b/crates/forge-core/src/rules/boards.rs @@ -0,0 +1,2685 @@ +//! Boards (`docs/design/boards.md`): the pure rules every client applies to a board's +//! documents, so `dg board` and the web show the same board. A port of forge-web's +//! `lib/rules/boards.ts`; the `board_*__*.json` vectors in `forge-contracts/vectors/` pin the +//! two together ([`tests::board_vectors`] here, `lib/rules/boards.conformance.test.ts` there). +//! +//! * **Spec** (§2.1–§2.3, §4, §8): the board definition a `board` document's `spec` holds, +//! parsed strictly ([`parse_spec`]) and written canonically ([`serialize_spec`]); a card's +//! field values ([`parse_field_values`], [`serialize_field_values`]). +//! * **Rank** (§2.6): base-62 fractional ranks ([`rank_between`], [`implicit_rank`], +//! [`top_rank`], [`bottom_rank`], [`rerank`]). +//! * **Fold** (§2.4): where every item shows ([`fold_board`]), and the newest board revision +//! per key ([`newest_boards`]). +//! * **Query** (§4.4): [`parse_board_query`], [`matches_board_query`]. +//! * **Iterations** (§2.2): [`iteration_at`], [`iteration_range`]. +//! * **Views** (§4.1–§4.5): [`group_rows`], [`sort_rows`], [`column_totals`], +//! [`iteration_progress`]. +//! +//! Everything is pure: no SDK, no clock (`now` is an input), no I/O. Strings compare by code +//! point (Rust's `str` order, the web's `compareStrings`). + +use std::cmp::Ordering; +use std::collections::{BTreeMap, HashMap, HashSet}; +use std::fmt::Write as _; + +use serde::{Deserialize, Serialize, Serializer}; +use serde_json::{Map, Value}; + +use super::search::{search_terms, tokens}; + +/// The vector case prefix: `board_rank`, `board_spec`, `board_fold`, `board_query`, +/// `board_iteration`, `board_view`. +pub const VECTOR_CASE_PREFIX: &str = "board_"; + +/// A `board.spec` holds at most this many UTF-8 bytes (the contract's `maxBytes`). +pub const SPEC_MAX_BYTES: usize = 4096; +/// A `card.f` holds at most this many UTF-8 bytes. +pub const FIELD_VALUES_MAX_BYTES: usize = 2048; +/// At most 20 status columns. +pub const MAX_COLUMNS: usize = 20; +/// At most 12 custom fields. +pub const MAX_FIELDS: usize = 12; +/// At most 30 options per single-select field. +pub const MAX_OPTIONS: usize = 30; +/// At most 5 sources. +pub const MAX_SOURCES: usize = 5; +/// At most 8 saved views. +pub const MAX_VIEWS: usize = 8; +/// A view lists at most this many table columns. +pub const MAX_VIEW_COLS: usize = 24; +/// Column, field, option and view names: 1–63 characters. +pub const NAME_MAX: usize = 63; +/// A board's description: at most this many characters. +pub const DESC_MAX: usize = 1024; +/// A source's or view's query: at most this many characters (the issue list's `Q_MAX`). +pub const QUERY_MAX: usize = 512; +/// A text field's value: 1–200 characters. +pub const TEXT_VALUE_MAX: usize = 200; +/// A column's WIP limit: 1–9999. +pub const WIP_MAX: i64 = 9999; +/// An iteration field's length: 1–90 days. +pub const ITER_DAYS_MAX: i64 = 90; +/// The highest iteration index a card may name. +pub const ITER_INDEX_MAX: i64 = 65535; +/// Auto-archive after at most this many days (0 = off). +pub const ARCH_MAX: i64 = 3650; +/// A number field's value: finite, |x| ≤ 1e15, and 0 or |x| ≥ 1e-6 (both clients print it alike). +pub const NUM_ABS_MAX: f64 = 1e15; +/// See [`NUM_ABS_MAX`]. +pub const NUM_ABS_MIN: f64 = 1e-6; +/// An explicit rank is at most 63 characters (the `card.rank` schema). +pub const RANK_MAX: usize = 63; +/// Ranks are re-spread for at most this many items at once. +pub const RERANK_MAX: u64 = 1_000_000; + +const DAY_MS: i64 = 86_400_000; + +// --------------------------------------------------------------------------------------------- +// Shared value shapes +// --------------------------------------------------------------------------------------------- + +/// A number or a string: a field value (an option id, a number, `YYYY-MM-DD`, an iteration +/// index, text), a query operand, a group key. A whole number serializes as a JSON integer, as +/// the web's `JSON.stringify` writes it. +#[derive(Debug, Clone, PartialEq)] +pub enum Scalar { + /// A number. + Num(f64), + /// A string. + Text(String), +} + +impl Scalar { + fn num(&self) -> Option { + match self { + Self::Num(x) => Some(*x), + Self::Text(_) => None, + } + } + + fn text(&self) -> Option<&str> { + match self { + Self::Num(_) => None, + Self::Text(t) => Some(t), + } + } + + /// As `String(v)` writes it. + fn display(&self) -> String { + match self { + Self::Num(x) => js_number(*x), + Self::Text(t) => t.clone(), + } + } +} + +impl From for Scalar { + #[allow(clippy::cast_precision_loss)] // ids, indices and counts: far below 2^53 + fn from(n: i64) -> Self { + Self::Num(n as f64) + } +} + +impl Serialize for Scalar { + #[allow(clippy::cast_possible_truncation, clippy::float_cmp)] // a whole number below 2^53 + fn serialize(&self, s: S) -> Result { + match self { + Self::Text(t) => s.serialize_str(t), + Self::Num(x) if x.fract() == 0.0 && x.abs() < 9_007_199_254_740_992.0 => { + s.serialize_i64(*x as i64) + } + Self::Num(x) => s.serialize_f64(*x), + } + } +} + +/// A finite number as JavaScript's `String(x)` writes it, for |x| in [1e-6, 1e21) or 0 (the +/// numbers a board stores and sums): ryu's shortest round-trip digits (JavaScript's, ties to +/// even; Rust's own `{}` rounds an exact tie up), written without an exponent; `-0` as `0`. +#[allow(clippy::float_cmp, clippy::cast_possible_truncation)] // -0 == 0; a whole number below 2^53 +fn js_number(x: f64) -> String { + if x == 0.0 { + return "0".into(); + } + if x.fract() == 0.0 && x.abs() < 9_007_199_254_740_992.0 { + return format!("{}", x as i64); + } + // serde_json writes f64 with ryu: `71292843364840.12`, `1.5e-6`, `1.152921504606847e+18` + let ryu = serde_json::to_string(&x).unwrap_or_default(); + let (sign, body) = ryu + .strip_prefix('-') + .map_or(("", ryu.as_str()), |b| ("-", b)); + let (mantissa, exp) = body + .split_once('e') + .map_or((body, 0), |(m, e)| (m, e.parse::().unwrap_or(0))); + let (int, frac) = mantissa.split_once('.').unwrap_or((mantissa, "")); + let all = format!("{int}{frac}"); + let digits = all.trim_start_matches('0'); + // the decimal point sits `point` digits into `digits` + let point = i64::try_from(int.len()).unwrap_or(0) + exp + - i64::try_from(all.len() - digits.len()).unwrap_or(0); + let digits = digits.trim_end_matches('0'); + let len = i64::try_from(digits.len()).unwrap_or(0); + let zeros = |n: i64| "0".repeat(usize::try_from(n).unwrap_or(0)); + if point <= 0 { + format!("{sign}0.{}{digits}", zeros(-point)) + } else if point >= len { + format!("{sign}{digits}{}", zeros(point - len)) + } else { + let at = usize::try_from(point).unwrap_or(0); + format!("{sign}{}.{}", &digits[..at], &digits[at..]) + } +} + +/// `s`'s length in characters (code points: the contract's `maxLength`). +fn char_len(s: &str) -> usize { + s.chars().count() +} + +/// The white space a name may not start or end with: JavaScript's `trim` set less the +/// controls (refused anyway). +fn is_space(c: char) -> bool { + matches!( + c as u32, + 0x20 | 0xa0 | 0x1680 | 0x2000 + ..=0x200a | 0x2028 | 0x2029 | 0x202f | 0x205f | 0x3000 | 0xfeff + ) +} + +/// C0, DEL and C1 control characters. +fn is_control(c: char) -> bool { + let x = c as u32; + x < 0x20 || (0x7f..=0x9f).contains(&x) +} + +/// A column, field, option or view name: 1–63 characters, no control character or `"` (a +/// query quotes names with `"`), not starting or ending with white space. +fn name_ok(s: &str) -> bool { + (1..=NAME_MAX).contains(&char_len(s)) + && !s.chars().any(|c| is_control(c) || c == '"') + && !s.chars().next().is_some_and(is_space) + && !s.chars().last().is_some_and(is_space) +} + +/// A JSON number that is a whole number in `min..=max` (the web's `Number.isInteger` check). +#[allow( + clippy::cast_possible_truncation, + clippy::cast_precision_loss, + clippy::float_cmp +)] +fn int_in(v: Option<&Value>, min: i64, max: i64) -> Option { + let x = v?.as_f64()?; + (x.fract() == 0.0 && x >= min as f64 && x <= max as f64).then_some(x as i64) +} + +/// A JSON string of at most `max` characters. +fn text_in(v: &Value, max: usize) -> Option { + v.as_str() + .filter(|s| char_len(s) <= max) + .map(str::to_string) +} + +fn is_color(s: &str) -> bool { + s.len() == 7 && s.starts_with('#') && s.bytes().skip(1).all(|b| b.is_ascii_hexdigit()) +} + +/// An identity or document id: 42–44 base58 characters (the web's `isIdentityId`). +fn is_identifier(s: &str) -> bool { + (42..=44).contains(&s.len()) + && s.bytes() + .all(|b| b.is_ascii_alphanumeric() && !matches!(b, b'0' | b'O' | b'I' | b'l')) +} + +/// Days since 1970-01-01 of a proleptic Gregorian date (Hinnant's `days_from_civil`). +fn days_from_civil(y: i64, m: i64, d: i64) -> i64 { + let yy = if m <= 2 { y - 1 } else { y }; + let era = yy.div_euclid(400); + let yoe = yy - era * 400; + let doy = (153 * (m + if m > 2 { -3 } else { 9 }) + 2) / 5 + d - 1; + let doe = yoe * 365 + yoe / 4 - yoe / 100 + doy; + era * 146_097 + doe - 719_468 +} + +/// The date `days` after 1970-01-01, as `YYYY-MM-DD` (Hinnant's `civil_from_days`). +fn civil_from_days(days: i64) -> String { + let z = days + 719_468; + let era = z.div_euclid(146_097); + let doe = z - era * 146_097; + let yoe = (doe - doe / 1460 + doe / 36524 - doe / 146_096) / 365; + let doy = doe - (365 * yoe + yoe / 4 - yoe / 100); + let mp = (5 * doy + 2) / 153; + let d = doy - (153 * mp + 2) / 5 + 1; + let m = if mp < 10 { mp + 3 } else { mp - 9 }; + let y = yoe + era * 400 + i64::from(m <= 2); + format!("{y:04}-{m:02}-{d:02}") +} + +/// A `YYYY-MM-DD` calendar date's day number (days since 1970-01-01), or `None`. +#[must_use] +pub fn date_days(s: &str) -> Option { + let bytes = s.as_bytes(); + if bytes.len() != 10 + || bytes[4] != b'-' + || bytes[7] != b'-' + || ![0, 1, 2, 3, 5, 6, 8, 9] + .iter() + .all(|&i| bytes[i].is_ascii_digit()) + { + return None; + } + let (y, m, d) = ( + s[0..4].parse::().ok()?, + s[5..7].parse::().ok()?, + s[8..10].parse::().ok()?, + ); + if y < 1 || !(1..=12).contains(&m) || d < 1 { + return None; + } + let leap = (y % 4 == 0 && y % 100 != 0) || y % 400 == 0; + let len = [ + 31, + if leap { 29 } else { 28 }, + 31, + 30, + 31, + 30, + 31, + 31, + 30, + 31, + 30, + 31, + ]; + (d <= len[usize::try_from(m - 1).ok()?]).then(|| days_from_civil(y, m, d)) +} + +/// The UTC date of a millisecond time, as `YYYY-MM-DD`. +#[must_use] +pub fn date_of(ms: i64) -> String { + civil_from_days(ms.div_euclid(DAY_MS)) +} + +fn is_zero(x: &T) -> bool { + *x == T::default() +} + +// --------------------------------------------------------------------------------------------- +// Spec (§2.1–§2.3, §4) +// --------------------------------------------------------------------------------------------- + +/// A status column (§2.1): `id` 1–255 stable across renames; order is the array order. +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct BoardColumn { + /// 1–255. + pub id: u8, + /// The column's name. + pub name: String, + /// `#rrggbb`. + #[serde(skip_serializing_if = "Option::is_none")] + pub color: Option, + /// WIP limit (§4.5): shown and warned on, never blocking. + #[serde(skip_serializing_if = "Option::is_none")] + pub wip: Option, +} + +/// The custom field types (§2.2). +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)] +#[serde(rename_all = "lowercase")] +pub enum FieldType { + /// Single select: an option id. + Sel, + /// A finite number. + Num, + /// `YYYY-MM-DD`. + Date, + /// An iteration index. + Iter, + /// Text, 1–200 characters. + Text, +} + +/// A single-select option. +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct FieldOption { + /// 1–255. + pub id: u8, + /// The option's name. + pub name: String, + /// `#rrggbb`. + #[serde(skip_serializing_if = "Option::is_none")] + pub color: Option, +} + +/// A custom field (§2.2). `options` is present exactly for `sel`; `start` (`YYYY-MM-DD`) and +/// `days` (1–90) exactly for `iter`. +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct BoardField { + /// 1–255. + pub id: u8, + /// The field's name. + pub name: String, + /// The type. + #[serde(rename = "type")] + pub kind: FieldType, + /// A `sel` field's options. + #[serde(skip_serializing_if = "Option::is_none")] + pub options: Option>, + /// An `iter` field's first day. + #[serde(skip_serializing_if = "Option::is_none")] + pub start: Option, + /// An `iter` field's length in days. + #[serde(skip_serializing_if = "Option::is_none")] + pub days: Option, +} + +/// A source's kind: issues, pull requests, or both. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)] +pub enum SourceKind { + /// Issues. + #[serde(rename = "i")] + Issues, + /// Pull requests. + #[serde(rename = "p")] + Pulls, + /// Both. + #[serde(rename = "a")] + All, +} + +/// An auto-include rule (§2.3): every item of repository `r` (absent: the home repository) of +/// kind `k` that query `q` matches is on the board ([`parse_source_query`]). +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct BoardSource { + /// The repository id. + #[serde(skip_serializing_if = "Option::is_none")] + pub r: Option, + /// The kind. + pub k: SourceKind, + /// The filter, empty for all. + #[serde(skip_serializing_if = "String::is_empty")] + pub q: String, +} + +/// A view's layout (§4.1–§4.3). +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)] +#[serde(rename_all = "lowercase")] +pub enum ViewLayout { + /// Columns of cards. + Board, + /// Rows. + Table, + /// A timeline. + Roadmap, +} + +/// A saved view (§4); its keys as the web's `BoardView` documents them (`status`, `assignee`, +/// `label`, `milestone`, `repo`, `f`, …). +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct BoardView { + /// 1–255. + pub id: u8, + /// The view's name. + pub name: String, + /// The layout. + pub layout: ViewLayout, + /// The filter. + #[serde(skip_serializing_if = "String::is_empty")] + pub q: String, + /// The grouping (board columns, table sections); absent is `status`. + #[serde(skip_serializing_if = "Option::is_none")] + pub group: Option, + /// Swimlanes. + #[serde(skip_serializing_if = "Option::is_none")] + pub lane: Option, + /// The sort, `-` first for descending; absent is `rank`. + #[serde(skip_serializing_if = "Option::is_none")] + pub sort: Option, + /// The fields shown. + #[serde(skip_serializing_if = "Option::is_none")] + pub cols: Option>, + /// The roadmap's dates: one `iter` field, or a start and an end `date` field. + #[serde(skip_serializing_if = "Option::is_none")] + pub date: Option>, +} + +/// A board definition, `v: 1` (§2). `def` / `done` are column ids, 0 for none; `arch` is +/// days, 0 = off. Serializes canonically: the declared key order, defaults omitted. +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct BoardSpec { + /// Always 1. + pub v: u8, + /// The description. + #[serde(skip_serializing_if = "Option::is_none")] + pub desc: Option, + /// 1–20 columns. + pub columns: Vec, + /// The default column. + #[serde(skip_serializing_if = "is_zero")] + pub def: u8, + /// The Done column. + #[serde(skip_serializing_if = "is_zero")] + pub done: u8, + /// Auto-include rules. + #[serde(skip_serializing_if = "Vec::is_empty")] + pub sources: Vec, + /// Custom fields. + #[serde(skip_serializing_if = "Vec::is_empty")] + pub fields: Vec, + /// Saved views. + #[serde(skip_serializing_if = "Vec::is_empty")] + pub views: Vec, + /// Auto-archive after this many days. + #[serde(skip_serializing_if = "is_zero")] + pub arch: u16, +} + +impl BoardSpec { + /// A field by id. + #[must_use] + pub fn field(&self, id: u8) -> Option<&BoardField> { + self.fields.iter().find(|f| f.id == id) + } + + fn column_index(&self, id: u8) -> Option { + self.columns.iter().position(|c| c.id == id) + } +} + +/// Why a spec was refused (the web's `SpecError`): not JSON or not an object, not `v: 1`, +/// over 4096 bytes, or the part that is malformed. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum SpecError { + /// Not JSON, or not an object. + Json, + /// Not `v: 1`. + Version, + /// Over 4096 bytes. + Size, + /// The description. + Desc, + /// The column list. + Columns, + /// A column (malformed or repeated). + Column, + /// `def`. + Def, + /// `done`. + Done, + /// The source list. + Sources, + /// A source. + Source, + /// The field list. + Fields, + /// A field (malformed, repeated or reserved). + Field, + /// A field's options. + Options, + /// The view list. + Views, + /// A view. + View, + /// `arch`. + Arch, +} + +impl SpecError { + /// The code both clients name it by. + #[must_use] + pub fn as_str(self) -> &'static str { + match self { + Self::Json => "json", + Self::Version => "version", + Self::Size => "size", + Self::Desc => "desc", + Self::Columns => "columns", + Self::Column => "column", + Self::Def => "def", + Self::Done => "done", + Self::Sources => "sources", + Self::Source => "source", + Self::Fields => "fields", + Self::Field => "field", + Self::Options => "options", + Self::Views => "views", + Self::View => "view", + Self::Arch => "arch", + } + } +} + +impl std::fmt::Display for SpecError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::error::Error for SpecError {} + +/// Names a field may not have, in any letter case: the query's own keys and the built-in +/// fields (§2.2, §4.4). +const RESERVED_FIELD_NAMES: &[&str] = &[ + "is", + "state", + "label", + "labels", + "assignee", + "assignees", + "author", + "milestone", + "no", + "status", + "repo", + "repository", + "title", + "number", + "created", +]; +const GROUP_BUILTINS: &[&str] = &["status", "assignee", "label", "milestone", "repo"]; +const SORT_BUILTINS: &[&str] = &[ + "rank", + "title", + "number", + "created", + "status", + "repo", + "author", + "milestone", +]; +const COL_BUILTINS: &[&str] = &[ + "title", + "number", + "repo", + "state", + "author", + "assignees", + "labels", + "milestone", + "created", + "status", +]; + +/// The field id a `f` key names (1–255, no leading zero). +#[must_use] +pub fn field_key_id(key: &str) -> Option { + let digits = key.strip_prefix('f')?; + if digits.is_empty() + || digits.len() > 3 + || digits.starts_with('0') + || !digits.bytes().all(|b| b.is_ascii_digit()) + { + return None; + } + digits.parse::().ok() +} + +fn field_of_key<'a>(fields: &'a [BoardField], key: &str) -> Option<&'a BoardField> { + let id = field_key_id(key)?; + fields.iter().find(|f| f.id == id) +} + +fn group_key_ok(fields: &[BoardField], key: &str, board_layout: bool) -> bool { + if key == "status" { + return true; + } + if GROUP_BUILTINS.contains(&key) { + return !board_layout; + } + field_of_key(fields, key).is_some_and(|f| matches!(f.kind, FieldType::Sel | FieldType::Iter)) +} + +fn sort_key_ok(fields: &[BoardField], key: &str) -> bool { + let k = key.strip_prefix('-').unwrap_or(key); + SORT_BUILTINS.contains(&k) || field_of_key(fields, k).is_some() +} + +fn col_key_ok(fields: &[BoardField], key: &str) -> bool { + COL_BUILTINS.contains(&key) || field_of_key(fields, key).is_some() +} + +/// Whether ids or names (in lower case) repeat. +fn repeats<'a>(entries: impl Iterator + Clone) -> bool { + let n = entries.clone().count(); + let ids: HashSet = entries.clone().map(|(id, _)| id).collect(); + let names: HashSet = entries.map(|(_, name)| name.to_lowercase()).collect(); + ids.len() != n || names.len() != n +} + +fn color_of(v: Option<&Value>, err: SpecError) -> Result, SpecError> { + match v { + None => Ok(None), + Some(v) => v + .as_str() + .filter(|s| is_color(s)) + .map(|s| Some(s.to_string())) + .ok_or(err), + } +} + +/// An entry's `id` (1–255) and `name`. +#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)] // 1..=255 +fn id_name(o: &Map, name_ok: impl Fn(&str) -> bool) -> Option<(u8, String)> { + let id = int_in(o.get("id"), 1, 255)? as u8; + let name = o.get("name")?.as_str().filter(|n| name_ok(n))?; + Some((id, name.to_string())) +} + +#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)] // 1..=9999 +fn parse_columns(v: Option<&Value>) -> Result, SpecError> { + let list = v + .and_then(Value::as_array) + .filter(|l| (1..=MAX_COLUMNS).contains(&l.len())) + .ok_or(SpecError::Columns)?; + let mut out = Vec::new(); + for c in list { + let o = c.as_object().ok_or(SpecError::Column)?; + let (id, name) = id_name(o, name_ok).ok_or(SpecError::Column)?; + let color = color_of(o.get("color"), SpecError::Column)?; + let wip = match o.get("wip") { + None => None, + Some(w) => Some(int_in(Some(w), 1, WIP_MAX).ok_or(SpecError::Column)? as u16), + }; + out.push(BoardColumn { + id, + name, + color, + wip, + }); + } + if repeats(out.iter().map(|c| (c.id, c.name.as_str()))) { + return Err(SpecError::Column); + } + Ok(out) +} + +#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)] // 0..=255 +fn parse_column_ref( + v: Option<&Value>, + columns: &[BoardColumn], + err: SpecError, +) -> Result { + let Some(v) = v else { return Ok(0) }; + let id = int_in(Some(v), 0, 255).ok_or(err)? as u8; + if id != 0 && !columns.iter().any(|c| c.id == id) { + return Err(err); + } + Ok(id) +} + +fn parse_sources(value: Option<&Value>) -> Result, SpecError> { + let Some(value) = value else { + return Ok(Vec::new()); + }; + let list = value + .as_array() + .filter(|l| l.len() <= MAX_SOURCES) + .ok_or(SpecError::Sources)?; + list.iter() + .map(|entry| { + let obj = entry.as_object().ok_or(SpecError::Source)?; + let r = match obj.get("r") { + None => None, + Some(repo) => Some( + repo.as_str() + .filter(|id| is_identifier(id)) + .ok_or(SpecError::Source)? + .to_string(), + ), + }; + let k = match obj.get("k").and_then(Value::as_str) { + Some("i") => SourceKind::Issues, + Some("p") => SourceKind::Pulls, + Some("a") => SourceKind::All, + _ => return Err(SpecError::Source), + }; + let q = match obj.get("q") { + None => String::new(), + Some(text) => text_in(text, QUERY_MAX).ok_or(SpecError::Source)?, + }; + Ok(BoardSource { r, k, q }) + }) + .collect() +} + +fn parse_options(v: Option<&Value>) -> Result, SpecError> { + let list = v + .and_then(Value::as_array) + .filter(|l| l.len() <= MAX_OPTIONS) + .ok_or(SpecError::Options)?; + let mut out = Vec::new(); + for o in list { + let o = o.as_object().ok_or(SpecError::Options)?; + let (id, name) = id_name(o, name_ok).ok_or(SpecError::Options)?; + let color = color_of(o.get("color"), SpecError::Options)?; + out.push(FieldOption { id, name, color }); + } + if repeats(out.iter().map(|o| (o.id, o.name.as_str()))) { + return Err(SpecError::Options); + } + Ok(out) +} + +fn field_name_ok(name: &str) -> bool { + name_ok(name) + && !name.contains(':') + && !name.starts_with('-') + && !RESERVED_FIELD_NAMES.contains(&name.to_lowercase().as_str()) +} + +#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)] // 1..=90 +fn parse_fields(v: Option<&Value>) -> Result, SpecError> { + let Some(v) = v else { return Ok(Vec::new()) }; + let list = v + .as_array() + .filter(|l| l.len() <= MAX_FIELDS) + .ok_or(SpecError::Fields)?; + let mut out = Vec::new(); + for f in list { + let o = f.as_object().ok_or(SpecError::Field)?; + let (id, name) = id_name(o, field_name_ok).ok_or(SpecError::Field)?; + let kind = match o.get("type").and_then(Value::as_str) { + Some("sel") => FieldType::Sel, + Some("num") => FieldType::Num, + Some("date") => FieldType::Date, + Some("iter") => FieldType::Iter, + Some("text") => FieldType::Text, + _ => return Err(SpecError::Field), + }; + if o.contains_key("options") != (kind == FieldType::Sel) { + return Err(SpecError::Field); + } + if (o.contains_key("start") || o.contains_key("days")) && kind != FieldType::Iter { + return Err(SpecError::Field); + } + let mut field = BoardField { + id, + name, + kind, + options: None, + start: None, + days: None, + }; + match kind { + FieldType::Sel => field.options = Some(parse_options(o.get("options"))?), + FieldType::Iter => { + let start = o + .get("start") + .and_then(Value::as_str) + .filter(|s| date_days(s).is_some()) + .ok_or(SpecError::Field)?; + let days = int_in(o.get("days"), 1, ITER_DAYS_MAX).ok_or(SpecError::Field)?; + field.start = Some(start.to_string()); + field.days = Some(days as u8); + } + _ => {} + } + out.push(field); + } + if repeats(out.iter().map(|f| (f.id, f.name.as_str()))) { + return Err(SpecError::Field); + } + Ok(out) +} + +/// An optional string member: `Ok(None)` absent, `Err` present but not a string. +fn opt_str(o: &Map, key: &str) -> Result, ()> { + match o.get(key) { + None => Ok(None), + Some(Value::String(s)) => Ok(Some(s.clone())), + Some(_) => Err(()), + } +} + +#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)] // 1..=255 +fn parse_view(w: &Value, fields: &[BoardField]) -> Option { + let o = w.as_object()?; + let (id, name) = id_name(o, name_ok)?; + let layout = match o.get("layout").and_then(Value::as_str)? { + "board" => ViewLayout::Board, + "table" => ViewLayout::Table, + "roadmap" => ViewLayout::Roadmap, + _ => return None, + }; + let q = match o.get("q") { + None => String::new(), + Some(q) => text_in(q, QUERY_MAX)?, + }; + let (group, lane, sort) = ( + opt_str(o, "group").ok()?, + opt_str(o, "lane").ok()?, + opt_str(o, "sort").ok()?, + ); + if group + .as_deref() + .is_some_and(|g| !group_key_ok(fields, g, layout == ViewLayout::Board)) + { + return None; + } + if let Some(l) = lane.as_deref() { + if l == "status" + || l == group.as_deref().unwrap_or("status") + || !group_key_ok(fields, l, false) + { + return None; + } + } + if sort.as_deref().is_some_and(|s| !sort_key_ok(fields, s)) { + return None; + } + let cols = match o.get("cols") { + None => None, + Some(c) => { + let list = c.as_array().filter(|l| l.len() <= MAX_VIEW_COLS)?; + let keys: Vec = list + .iter() + .map(|k| { + k.as_str() + .filter(|k| col_key_ok(fields, k)) + .map(str::to_string) + }) + .collect::>()?; + if keys.iter().collect::>().len() != keys.len() { + return None; + } + Some(keys) + } + }; + let date = match o.get("date") { + None => None, + Some(d) => { + let ids: Vec = d + .as_array()? + .iter() + .map(|x| int_in(Some(x), 1, 255).map(|x| x as u8)) + .collect::>()?; + let types: Vec> = ids + .iter() + .map(|id| fields.iter().find(|f| f.id == *id).map(|f| f.kind)) + .collect(); + let iter = types == [Some(FieldType::Iter)]; + let range = types == [Some(FieldType::Date), Some(FieldType::Date)] && ids[0] != ids[1]; + if !iter && !range { + return None; + } + Some(ids) + } + }; + Some(BoardView { + id, + name, + layout, + q, + group, + lane, + sort, + cols, + date, + }) +} + +fn parse_views(v: Option<&Value>, fields: &[BoardField]) -> Result, SpecError> { + let Some(v) = v else { return Ok(Vec::new()) }; + let list = v + .as_array() + .filter(|l| l.len() <= MAX_VIEWS) + .ok_or(SpecError::Views)?; + let out: Vec = list + .iter() + .map(|w| parse_view(w, fields).ok_or(SpecError::View)) + .collect::>()?; + if repeats(out.iter().map(|w| (w.id, w.name.as_str()))) { + return Err(SpecError::View); + } + Ok(out) +} + +/// Read a board definition (`board.spec`, §2): JSON, `v: 1`, at most 4096 UTF-8 bytes, every +/// limit of §8, ids 1–255 and unique, names unique in any letter case, every reference (`def`, +/// `done`, a view's keys) to something the spec defines. Unknown keys are tolerated and +/// dropped by [`serialize_spec`]; a known key of the wrong type or shape refuses the spec. +/// Checked in the canonical key order, so both clients name the same first problem. +#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)] // arch 0..=3650 +pub fn parse_spec(json: &str) -> Result { + if json.len() > SPEC_MAX_BYTES { + return Err(SpecError::Size); + } + let raw: Value = serde_json::from_str(json).map_err(|_| SpecError::Json)?; + let Value::Object(raw) = raw else { + return Err(SpecError::Json); + }; + if int_in(raw.get("v"), 1, 1).is_none() { + return Err(SpecError::Version); + } + // an empty description is none (written as none) + let desc = match raw.get("desc") { + None => None, + Some(d) => Some(text_in(d, DESC_MAX).ok_or(SpecError::Desc)?).filter(|d| !d.is_empty()), + }; + let columns = parse_columns(raw.get("columns"))?; + let def = parse_column_ref(raw.get("def"), &columns, SpecError::Def)?; + let done = parse_column_ref(raw.get("done"), &columns, SpecError::Done)?; + let sources = parse_sources(raw.get("sources"))?; + let fields = parse_fields(raw.get("fields"))?; + let views = parse_views(raw.get("views"), &fields)?; + let arch = match raw.get("arch") { + None => 0, + Some(a) => int_in(Some(a), 0, ARCH_MAX).ok_or(SpecError::Arch)? as u16, + }; + Ok(BoardSpec { + v: 1, + desc, + columns, + def, + done, + sources, + fields, + views, + arch, + }) +} + +/// Write a definition as canonical compact JSON (the declared key order, defaults omitted), +/// so equal specs are equal bytes in both clients. Refused when it would not read back +/// ([`parse_spec`]'s error) or is over 4096 bytes: what this returns always parses to an +/// equal spec. +pub fn serialize_spec(spec: &BoardSpec) -> Result { + let json = serde_json::to_string(spec).map_err(|_| SpecError::Json)?; + let back = parse_spec(&json)?; + serde_json::to_string(&back).map_err(|_| SpecError::Json) +} + +/// The Monday (UTC) of the week holding `ms`, as `YYYY-MM-DD`. +#[must_use] +pub fn monday_of(ms: i64) -> String { + let days = ms.div_euclid(DAY_MS); + // 1970-01-01 was a Thursday: (days + 3) mod 7 is days since Monday + civil_from_days(days - (days + 3).rem_euclid(7)) +} + +/// The new-board template: Todo / In progress / Done (Done the done column, Todo the +/// default), the home repository's issues and pull requests, Priority (P0–P3), Estimate and a +/// two-week Iteration starting the Monday of the week of `now_ms`, a Board, a Table and a +/// Roadmap view, and auto-archive after 14 days. +#[must_use] +pub fn default_spec(home_repo_id: &str, now_ms: i64) -> BoardSpec { + let column = |id, name: &str| BoardColumn { + id, + name: name.into(), + color: None, + wip: None, + }; + let option = |id, name: &str, color: &str| FieldOption { + id, + name: name.into(), + color: Some(color.into()), + }; + let field = |id, name: &str, kind| BoardField { + id, + name: name.into(), + kind, + options: None, + start: None, + days: None, + }; + let view = |id, name: &str, layout| BoardView { + id, + name: name.into(), + layout, + q: String::new(), + group: None, + lane: None, + sort: None, + cols: None, + date: None, + }; + BoardSpec { + v: 1, + desc: None, + columns: vec![ + column(1, "Todo"), + column(2, "In progress"), + column(3, "Done"), + ], + def: 1, + done: 3, + sources: vec![BoardSource { + r: Some(home_repo_id.to_string()), + k: SourceKind::All, + q: String::new(), + }], + fields: vec![ + BoardField { + options: Some(vec![ + option(1, "P0", "#d1242f"), + option(2, "P1", "#fb8f44"), + option(3, "P2", "#d4a72c"), + option(4, "P3", "#8c959f"), + ]), + ..field(1, "Priority", FieldType::Sel) + }, + field(2, "Estimate", FieldType::Num), + BoardField { + start: Some(monday_of(now_ms)), + days: Some(14), + ..field(3, "Iteration", FieldType::Iter) + }, + ], + views: vec![ + view(1, "Board", ViewLayout::Board), + BoardView { + cols: Some( + ["title", "status", "assignees", "f1", "f2", "f3"] + .map(String::from) + .to_vec(), + ), + ..view(2, "Table", ViewLayout::Table) + }, + BoardView { + date: Some(vec![3]), + ..view(3, "Roadmap", ViewLayout::Roadmap) + }, + ], + arch: 14, + } +} + +// --------------------------------------------------------------------------------------------- +// Card field values (§3.2 `f`) +// --------------------------------------------------------------------------------------------- + +/// A card's field values by field id (ascending, as JSON keys). +pub type FieldValues = BTreeMap; + +/// `v` as a value of `field`, if it is a valid one (`-0` reads as 0). +#[allow(clippy::float_cmp)] // -0 == 0 +fn field_value(field: &BoardField, v: &Value) -> Option { + match field.kind { + FieldType::Sel => { + let id = int_in(Some(v), 1, 255)?; + field + .options + .as_deref() + .unwrap_or_default() + .iter() + .any(|o| i64::from(o.id) == id) + .then(|| Scalar::from(id)) + } + FieldType::Num => { + let x = v.as_f64().filter(|x| x.is_finite())?; + (x.abs() <= NUM_ABS_MAX && (x == 0.0 || x.abs() >= NUM_ABS_MIN)) + .then_some(Scalar::Num(if x == 0.0 { 0.0 } else { x })) + } + FieldType::Date => v + .as_str() + .filter(|s| date_days(s).is_some()) + .map(|s| Scalar::Text(s.to_string())), + FieldType::Iter => int_in(Some(v), 0, ITER_INDEX_MAX).map(Scalar::from), + FieldType::Text => v + .as_str() + .filter(|s| !s.is_empty() && char_len(s) <= TEXT_VALUE_MAX) + .map(|s| Scalar::Text(s.to_string())), + } +} + +/// `v` as a value of `field` (the web's `fieldValueOk`): the value a card stores, or `None` +/// when the field's type refuses it (an unknown option, a non-finite or out-of-range number, a +/// date that is no calendar day, an iteration past 65535, empty or long text). +#[must_use] +pub fn field_value_ok(field: &BoardField, v: &Value) -> Option { + field_value(field, v) +} + +/// The `board.name` schema (§3.1, the web's `BOARD_NAME` in `lib/repo/board-writes.ts`): 1–63 +/// characters, at most 252 UTF-8 bytes, no C0 control character or DEL, and at least one +/// character that is not white space (JavaScript's `\s`). +#[must_use] +pub fn is_board_name(s: &str) -> bool { + let c0 = |c: char| (c as u32) < 0x20 || c == '\u{7f}'; + (1..=NAME_MAX).contains(&char_len(s)) + && s.len() <= 252 + && !s.chars().any(c0) + && s.chars().any(|c| !is_space(c)) +} + +fn valid_values<'a>( + entries: impl Iterator, + spec: &BoardSpec, +) -> FieldValues { + let mut out = FieldValues::new(); + for (key, v) in entries { + let canonical = !key.is_empty() + && key.len() <= 3 + && !key.starts_with('0') + && key.bytes().all(|b| b.is_ascii_digit()); + let Some(field) = canonical + .then(|| key.parse::().ok()) + .flatten() + .and_then(|id| spec.field(id)) + else { + continue; + }; + if let Some(value) = field_value(field, v) { + out.insert(field.id, value); + } + } + out +} + +/// A card's field values (`card.f`, `{"": value}`), keeping only those `spec` +/// defines with a value of the field's type (a deleted field, a deleted option, a wrong type +/// are dropped). Not JSON or not an object reads as none. +#[must_use] +pub fn parse_field_values(json: Option<&str>, spec: &BoardSpec) -> FieldValues { + let Some(json) = json.filter(|j| !j.is_empty()) else { + return FieldValues::new(); + }; + match serde_json::from_str::(json) { + Ok(Value::Object(o)) => valid_values(o.iter(), spec), + _ => FieldValues::new(), + } +} + +/// Field values as canonical JSON (ids ascending, invalid entries dropped as +/// [`parse_field_values`] drops them, numbers as JavaScript writes them); `None` over 2048 +/// bytes. +#[must_use] +pub fn serialize_field_values(values: &FieldValues, spec: &BoardSpec) -> Option { + let mut out = String::from("{"); + for (id, v) in values { + let Some(field) = spec.field(*id) else { + continue; + }; + let raw = match v { + Scalar::Num(x) => serde_json::Number::from_f64(*x).map(Value::Number), + Scalar::Text(t) => Some(Value::String(t.clone())), + }; + if raw.and_then(|r| field_value(field, &r)).is_none() { + continue; + } + if out.len() > 1 { + out.push(','); + } + let _ = write!(out, "\"{id}\":"); + match v { + Scalar::Num(x) => out.push_str(&js_number(*x)), + Scalar::Text(t) => out.push_str(&serde_json::to_string(t).unwrap_or_default()), + } + } + out.push('}'); + (out.len() <= FIELD_VALUES_MAX_BYTES).then_some(out) +} + +// --------------------------------------------------------------------------------------------- +// Rank (§2.6) +// --------------------------------------------------------------------------------------------- + +/// The 62 rank digits, in ASCII (byte) order. +pub const RANK_DIGITS: &[u8; 62] = + b"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + +/// A rank digit's value 0–61. +fn digit_of(c: u8) -> Option { + match c { + b'0'..=b'9' => Some(u32::from(c - b'0')), + b'A'..=b'Z' => Some(u32::from(c - b'A') + 10), + b'a'..=b'z' => Some(u32::from(c - b'a') + 36), + _ => None, + } +} + +fn digit(x: u32) -> char { + char::from(RANK_DIGITS[x as usize]) +} + +/// Whether `r` is a well-formed explicit rank: 1–63 digits, not ending in `0` (the +/// `card.rank` pattern). +#[must_use] +pub fn is_explicit_rank(r: &str) -> bool { + (1..=RANK_MAX).contains(&r.len()) + && r.bytes().all(|b| digit_of(b).is_some()) + && !r.ends_with('0') +} + +/// Why no rank was made (the web's `RankError`). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum RankError { + /// A bound is not 0–63 rank digits. + Invalid, + /// The lower bound is above the upper. + Order, + /// No rank of at most 63 digits fits (the bounds are equal, or `b` is `a` + `0…0`, or the + /// gap is used up): re-rank the column (§2.6). + Rerank, +} + +impl RankError { + /// The code both clients name it by. + #[must_use] + pub fn as_str(self) -> &'static str { + match self { + Self::Invalid => "invalid", + Self::Order => "order", + Self::Rerank => "re-rank", + } + } +} + +impl std::fmt::Display for RankError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(match self { + Self::Rerank => "Re-rank this column", + other => other.as_str(), + }) + } +} + +impl std::error::Error for RankError {} + +/// A rank strictly between `a` and `b` in byte order (`""` is open: below everything / above +/// everything), ending in a non-zero digit, at most 63 digits: the web's `rankBetween`, whose +/// comment gives the construction and why it is strictly between. +pub fn rank_between(a: &str, b: &str) -> Result { + let ok = |r: &str| r.len() <= RANK_MAX && r.bytes().all(|c| digit_of(c).is_some()); + if !ok(a) || !ok(b) { + return Err(RankError::Invalid); + } + if !b.is_empty() && a >= b { + // two members dropping into one gap at once write one rank: nothing lies between them + return Err(if a == b { + RankError::Rerank + } else { + RankError::Order + }); + } + let (lo, hi) = (a.as_bytes(), b.as_bytes()); + let mut out = String::new(); + let mut lo_tight = true; + let mut hi_tight = !hi.is_empty(); + for i in 0.. { + if i >= RANK_MAX || (hi_tight && i >= hi.len()) { + return Err(RankError::Rerank); + } + let in_lo = lo_tight && i < lo.len(); + let floor = if in_lo { + digit_of(lo[i]).unwrap_or(0) + } else { + 0 + }; + let hd = if hi_tight { + digit_of(hi[i]).unwrap_or(0) + } else { + 62 + }; + let ceil = if hi_tight && i + 1 < hi.len() { + hd + 1 + } else { + hd + }; + if ceil >= floor + 2 { + out.push(digit(floor.midpoint(ceil))); + return Ok(out); + } + lo_tight = in_lo; + hi_tight = hi_tight && floor == hd; + out.push(digit(floor)); + } + unreachable!("the loop returns by RANK_MAX") +} + +/// `n` in `width` base-62 digits (clamped to 0 … 62^width − 1). +fn base62(n: i64, width: u32) -> String { + let max = 62_i64.pow(width) - 1; + let mut v = n.clamp(0, max); + let mut out = vec![b'0'; width as usize]; + for slot in out.iter_mut().rev() { + *slot = RANK_DIGITS[usize::try_from(v % 62).unwrap_or(0)]; + v /= 62; + } + String::from_utf8(out).unwrap_or_default() +} + +/// The rank of an item with no card, or whose newest card has no rank: `V`, its +/// `$createdAt` in 8 base-62 digits, the first 3 bytes of its `$id` (big-endian, mod 62⁴) in 4. +#[must_use] +pub fn implicit_rank(created_at_ms: i64, item_id_bytes: &[u8]) -> String { + let byte = |i: usize| i64::from(item_id_bytes.get(i).copied().unwrap_or(0)); + let head = (byte(0) << 16) | (byte(1) << 8) | byte(2); + format!( + "V{}{}", + base62(created_at_ms, 8), + base62(head % 62_i64.pow(4), 4) + ) +} + +/// The bytes of a base58 id (the web's `base58Decode`); none when it is not base58. +fn base58_bytes(s: &str) -> Vec { + const ALPHABET: &[u8] = b"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; + // little-endian magnitude + let mut le: Vec = Vec::new(); + for c in s.bytes() { + let Some(d) = ALPHABET.iter().position(|&a| a == c) else { + return Vec::new(); + }; + let mut carry = u32::try_from(d).unwrap_or(0); + for b in &mut le { + carry += u32::from(*b) * 58; + *b = (carry & 0xff) as u8; + carry >>= 8; + } + while carry > 0 { + le.push((carry & 0xff) as u8); + carry >>= 8; + } + } + let zeros = s.bytes().take_while(|&c| c == b'1').count(); + let mut out = vec![0; zeros]; + out.extend(le.iter().rev()); + out +} + +/// [`implicit_rank`] of an item by its base58 `$id`. +#[must_use] +pub fn implicit_rank_of(created_at_ms: i64, item_id: &str) -> String { + implicit_rank(created_at_ms, &base58_bytes(item_id)) +} + +/// The rank that puts a card at the top of a column whose first rank is `first` (`None`: +/// empty), above the sourced pool. +pub fn top_rank(first: Option<&str>) -> Result { + rank_between("", first.filter(|f| *f <= "V").unwrap_or("V")) +} + +/// The rank that puts a card at the bottom of a column whose last rank is `last` (`None`: +/// empty), below the sourced pool. +pub fn bottom_rank(last: Option<&str>) -> Result { + rank_between(last.filter(|l| *l >= "W").unwrap_or("W"), "") +} + +/// `n` evenly spaced explicit ranks, ascending, for re-ranking a column (§2.6): rank k is +/// k/(n+1) of the way from `0` to `V`, in the fewest digits that leave 62 free ranks between +/// neighbours, trailing zeros dropped. `Invalid` past 1 000 000. +pub fn rerank(n: u64) -> Result, RankError> { + if n > RERANK_MAX { + return Err(RankError::Invalid); + } + let n = i64::try_from(n).map_err(|_| RankError::Invalid)?; + let mut width = 1; + while 31 * 62_i64.pow(width - 1) < 62 * (n + 1) { + width += 1; + } + let space = 31 * 62_i64.pow(width - 1); + Ok((1..=n) + .map(|k| { + base62(k * space / (n + 1), width) + .trim_end_matches('0') + .to_string() + }) + .collect()) +} + +// --------------------------------------------------------------------------------------------- +// Iterations (§2.2) +// --------------------------------------------------------------------------------------------- + +/// One iteration of an `iter` field: index k, named " k+1", `start` … `end` (the last +/// day, inclusive). +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct IterationRange { + /// k. + pub index: i64, + /// " k+1". + pub name: String, + /// The first day. + pub start: String, + /// The last day. + pub end: String, + /// `start`'s midnight UTC. + pub start_ms: i64, + /// The next iteration's (exclusive end). + pub end_ms: i64, +} + +/// An `iter` field's first day number and length. +fn iter_of(field: &BoardField) -> Option<(i64, i64)> { + if field.kind != FieldType::Iter { + return None; + } + let days = i64::from(field.days.filter(|d| *d > 0)?); + Some((date_days(field.start.as_deref()?)?, days)) +} + +/// The index of `field`'s iteration holding `date_ms` (UTC days); `None` before its first or +/// past index 65535, or not an `iter` field. +#[must_use] +pub fn iteration_at(field: &BoardField, date_ms: i64) -> Option { + let (start, days) = iter_of(field)?; + let k = (date_ms.div_euclid(DAY_MS) - start).div_euclid(days); + (0..=ITER_INDEX_MAX).contains(&k).then_some(k) +} + +/// Iteration `k` of `field`; `None` when not an `iter` field or `k` out of range. +#[must_use] +pub fn iteration_range(field: &BoardField, k: i64) -> Option { + let (start, days) = iter_of(field)?; + if !(0..=ITER_INDEX_MAX).contains(&k) { + return None; + } + let first = start + k * days; + let next = first + days; + Some(IterationRange { + index: k, + name: format!("{} {}", field.name, k + 1), + start: civil_from_days(first), + end: civil_from_days(next - 1), + start_ms: first * DAY_MS, + end_ms: next * DAY_MS, + }) +} + +// --------------------------------------------------------------------------------------------- +// Items, cards and placement (§2.4) +// --------------------------------------------------------------------------------------------- + +/// An issue or a pull request. +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum ItemKind { + /// An issue. + Issue, + /// A pull request. + Pr, +} + +/// An item's state. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum ItemState { + /// Open. + Open, + /// Closed (not merged). + Closed, + /// Merged. + Merged, +} + +/// What a board reads of an issue or PR (the web's `BoardItem`). +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct BoardItem { + /// The item's `$id`. + pub id: String, + /// Its number. + pub number: u64, + /// Its repository's id. + pub repo_id: String, + /// How this client labels the item's repository (`owner/name`), for display only: + /// `repo:`, grouping and sorting read [`Self::repo_id`]. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub repo: Option, + /// Issue or PR. + pub kind: ItemKind, + /// Open, closed or merged. + pub state: ItemState, + /// Its `$createdAt`. + pub created_at: i64, + /// The `$createdAt` of its latest transition into closed or merged. + pub closed_at: Option, + /// The title. + pub title: String, + /// Label names. + pub labels: Vec, + /// Assignee identity ids. + pub assignees: Vec, + /// The milestone's title. + pub milestone: Option, + /// The author's identity id. + pub author: String, +} + +/// Card `state` (§3.2): active. +pub const CARD_ACTIVE: i64 = 0; +/// Archived. +pub const CARD_ARCHIVED: i64 = 1; +/// Removed. +pub const CARD_REMOVED: i64 = 2; + +/// A `card` document as read (a private repo's opened); `col` / `rank` / `f` `None` when +/// absent or unreadable. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct CardDoc { + /// `$id`. + pub id: String, + /// `$ownerId`. + pub owner_id: String, + /// `$updatedAt`. + pub updated_at: i64, + /// The item's `$id`. + pub item: String, + /// The column id. + pub col: Option, + /// The rank. + pub rank: Option, + /// The field values' JSON. + pub f: Option, + /// 0 active, 1 archived, 2 removed. + pub state: i64, +} + +/// Why an item is archived. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)] +#[serde(rename_all = "lowercase")] +pub enum ArchivedBy { + /// Its newest card says so. + Card, + /// Auto-archive (`arch`). + Auto, +} + +/// Where one item shows (§2.4). `col` 0 is "No status". +#[derive(Debug, Clone, PartialEq, Serialize)] +pub struct Placement { + /// The item's `$id`. + pub id: String, + /// On the board: a source matches it or it has a card, and that card is not removed. + pub on: bool, + /// A source matches it. + pub sourced: bool, + /// Its newest card removed it. + pub removed: bool, + /// The newest card's `$id`. + pub card: Option, + /// The column. + pub col: u8, + /// The effective rank. + pub rank: String, + /// Why it is archived, if it is. + pub archived: Option, + /// Its field values. + pub fields: FieldValues, +} + +/// A column's visible items (on the board, not archived), in rank order. +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct ColumnItems { + /// The column id (0: "No status"). + pub id: u8, + /// Item ids. + pub items: Vec, +} + +/// A board folded (the web's `BoardFold`). +#[derive(Debug, Clone, PartialEq, Serialize)] +pub struct BoardFold { + /// One per input item, in input order (repeated ids once). + pub items: Vec, + /// "No status" (0) first while it holds an item, then every column in order. + pub columns: Vec, +} + +/// Whether `(a_at, a_id)` is newer than `(b_at, b_id)`. +fn newer(a_at: i64, a_id: &str, b_at: i64, b_id: &str) -> bool { + (a_at, a_id) > (b_at, b_id) +} + +/// Every item's newest card over every member's, by (`$updatedAt`, `$id`) (§2.4). +#[must_use] +pub fn newest_cards(cards: &[CardDoc]) -> HashMap<&str, &CardDoc> { + let mut out: HashMap<&str, &CardDoc> = HashMap::new(); + for c in cards { + match out.get(c.item.as_str()) { + Some(prev) if !newer(c.updated_at, &c.id, prev.updated_at, &prev.id) => {} + _ => { + out.insert(&c.item, c); + } + } + } + out +} + +/// A `board` document as read; `spec` `None` when absent or unreadable. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct BoardDoc { + /// `$id`. + pub id: String, + /// `$ownerId`. + pub owner_id: String, + /// `$updatedAt`. + pub updated_at: i64, + /// The board's key. + pub key: u32, + /// 0 open, 1 closed, 2 deleted. + pub state: i64, + /// The name. + pub name: Option, + /// The definition's JSON. + pub spec: Option, +} + +/// Board `state` (§3.1): deleted. +pub const BOARD_DELETED: i64 = 2; + +/// A repository's boards: per key the newest revision over every member's by +/// (`$updatedAt`, `$id`), ascending by key, less the deleted ones unless `with_deleted`. +#[must_use] +pub fn newest_boards(docs: &[BoardDoc], with_deleted: bool) -> Vec<&BoardDoc> { + let mut by_key: BTreeMap = BTreeMap::new(); + for d in docs { + match by_key.get(&d.key) { + Some(prev) if !newer(d.updated_at, &d.id, prev.updated_at, &prev.id) => {} + _ => { + by_key.insert(d.key, d); + } + } + } + by_key + .into_values() + .filter(|d| with_deleted || d.state != BOARD_DELETED) + .collect() +} + +/// Whether `source` includes `item` (§2.3): its repository (absent: `home`) and kind, and the +/// qualifiers of its query (`query`, [`parse_source_query`] of `source.q`). +#[must_use] +pub fn source_matches( + source: &BoardSource, + query: &BoardQuery, + item: &BoardItem, + home: &str, + spec: &BoardSpec, + now: i64, +) -> bool { + if source.r.as_deref().unwrap_or(home) != item.repo_id { + return false; + } + match source.k { + SourceKind::Issues if item.kind != ItemKind::Issue => return false, + SourceKind::Pulls if item.kind != ItemKind::Pr => return false, + _ => {} + } + query_holds(item, None, spec, query, &QueryContext { me: None, now }) +} + +/// Where every item shows (§2.4): the web's `foldBoard`, whose comment states the rules. +#[must_use] +pub fn fold_board( + spec: &BoardSpec, + home: &str, + items: &[BoardItem], + cards: &[CardDoc], + now: i64, +) -> BoardFold { + let newest = newest_cards(cards); + let source_queries: Vec<(&BoardSource, BoardQuery)> = spec + .sources + .iter() + .map(|s| (s, parse_source_query(&s.q, spec))) + .collect(); + let done_index = (spec.done != 0) + .then(|| spec.column_index(spec.done)) + .flatten(); + let mut seen = HashSet::new(); + let mut out = Vec::new(); + for item in items { + if !seen.insert(item.id.as_str()) { + continue; + } + let card = newest.get(item.id.as_str()).copied(); + let sourced = source_queries + .iter() + .any(|(s, q)| source_matches(s, q, item, home, spec, now)); + let removed = card.is_some_and(|c| c.state == CARD_REMOVED); + let card_col = card + .and_then(|c| c.col) + .and_then(|c| u8::try_from(c).ok()) + .filter(|c| spec.column_index(*c).is_some()); + let finished = item.state != ItemState::Open; + let keeps = |d: usize| { + card_col + .and_then(|c| spec.column_index(c)) + .is_some_and(|i| i >= d) + }; + let col = match done_index { + Some(d) if finished && !keeps(d) => spec.done, + _ => card_col.unwrap_or(spec.def), + }; + let archived = if card.is_some_and(|c| c.state == CARD_ARCHIVED) { + Some(ArchivedBy::Card) + } else { + match item.closed_at { + Some(closed) + if spec.arch > 0 + && finished + && card.is_none_or(|c| c.updated_at < closed) + && now >= closed + i64::from(spec.arch) * DAY_MS => + { + Some(ArchivedBy::Auto) + } + _ => None, + } + }; + out.push(Placement { + id: item.id.clone(), + on: (sourced || card.is_some()) && !removed, + sourced, + removed, + card: card.map(|c| c.id.clone()), + col, + rank: card + .and_then(|c| c.rank.clone()) + .filter(|r| is_explicit_rank(r)) + .unwrap_or_else(|| implicit_rank_of(item.created_at, &item.id)), + archived, + fields: card.map_or_else(FieldValues::new, |c| { + parse_field_values(c.f.as_deref(), spec) + }), + }); + } + let mut visible: Vec<&Placement> = out + .iter() + .filter(|p| p.on && p.archived.is_none()) + .collect(); + visible.sort_by(|a, b| by_rank(&a.rank, &a.id, &b.rank, &b.id)); + let in_col = |id: u8| -> Vec { + visible + .iter() + .filter(|p| p.col == id) + .map(|p| p.id.clone()) + .collect() + }; + let none = in_col(0); + let mut columns = Vec::new(); + if !none.is_empty() { + columns.push(ColumnItems { id: 0, items: none }); + } + columns.extend(spec.columns.iter().map(|c| ColumnItems { + id: c.id, + items: in_col(c.id), + })); + BoardFold { + items: out, + columns, + } +} + +/// Order within a column (§2.6): (rank, item `$id`), both by code point. +#[must_use] +pub fn by_rank(a_rank: &str, a_id: &str, b_rank: &str, b_id: &str) -> Ordering { + (a_rank, a_id).cmp(&(b_rank, b_id)) +} + +// --------------------------------------------------------------------------------------------- +// Query (§4.4) +// --------------------------------------------------------------------------------------------- + +/// One qualifier (the web's `QueryPred`): every one ANDed, `not` for a leading `-`. +#[derive(Debug, Clone, PartialEq, Serialize)] +pub struct QueryPred { + /// `is`, `label`, `milestone`, `assignee`, `author`, `repo`, `status`, `no` or `field`. + pub k: &'static str, + /// A leading `-`. + pub not: bool, + /// The value. + #[serde(skip_serializing_if = "Option::is_none")] + pub v: Option, + /// A `field` predicate's field id. + #[serde(skip_serializing_if = "Option::is_none")] + pub f: Option, + /// `eq`, `gt`, `ge`, `lt`, `le`, `range` or `has`. + #[serde(skip_serializing_if = "Option::is_none")] + pub op: Option<&'static str>, + /// A range's upper end. + #[serde(skip_serializing_if = "Option::is_none")] + pub v2: Option, +} + +impl QueryPred { + fn of(k: &'static str, not: bool, v: Scalar) -> Self { + Self { + k, + not, + v: Some(v), + f: None, + op: None, + v2: None, + } + } + + fn v_text(&self) -> &str { + self.v.as_ref().and_then(Scalar::text).unwrap_or("") + } +} + +/// A parsed board query. +#[derive(Debug, Clone, PartialEq, Serialize)] +pub struct BoardQuery { + /// The qualifiers. + pub preds: Vec, + /// The free text: matched against titles, `#12` / `12` against numbers. + pub text: String, + /// The qualifier tokens not applied, as typed. + pub unresolved: Vec, +} + +const IS_VALUES: &[&str] = &[ + "open", "closed", "merged", "unmerged", "issue", "pr", "archived", +]; +const STATE_VALUES: &[&str] = &["open", "closed", "merged", "unmerged"]; +const QUERY_KEYS: &[&str] = &[ + "is", + "state", + "label", + "milestone", + "assignee", + "author", + "repo", + "status", + "no", +]; +const LABEL_MAX: usize = 30; +const MILESTONE_MAX: usize = 63; +const ITER_RELATIVE: &[&str] = &["@current", "@next", "@previous"]; + +fn unquote(s: &str) -> String { + s.replace('"', "") +} + +/// A query token's parts (the web's `tokenParts`): its key (lowercased, unquoted, without a +/// leading `-`), whether it is negated, its raw value and its unquoted value; `None` for no key. +fn token_parts(tok: &str) -> Option<(String, bool, &str, String)> { + let at = tok.find(':').filter(|&at| at > 0)?; + let raw_key = &tok[..at]; + let not = raw_key.len() > 1 && raw_key.starts_with('-'); + let key = unquote(if not { &raw_key[1..] } else { raw_key }).to_lowercase(); + let raw_value = &tok[at + 1..]; + Some((key, not, raw_value, unquote(raw_value))) +} + +/// The repositories `text`'s `repo:` qualifiers name by name, as typed (unquoted), each once, +/// in order (the web's `repoNamesOf`): `owner/name` (the owner an identity id or a DPNS name) +/// or a bare `name` (a repository of the home repository's owner). A client resolves each to +/// its repository id before parsing ([`parse_board_query`]'s `repos`), so `repo:` matches by id +/// and never by how a client labels a repository; a value that is itself an id is not listed. +#[must_use] +pub fn repo_names_of(text: &str) -> Vec { + let mut out: Vec = Vec::new(); + for tok in tokens(text) { + let Some((key, _, raw_value, value)) = token_parts(&tok) else { + continue; + }; + if key != "repo" + || value.is_empty() + || raw_value.starts_with("//") + || is_identifier(&value) + || out.contains(&value) + { + continue; + } + out.push(value); + } + out +} + +/// A person value: an identity id, or `me` (`@me`, any case). +fn person_of(v: &str) -> Option { + let t = v.strip_prefix('@').unwrap_or(v); + if t.to_lowercase() == "me" { + return Some("me".into()); + } + is_identifier(t).then(|| t.to_string()) +} + +/// A comparison value's op and operand(s), still text. +fn comparison(v: &str) -> (&'static str, &str, Option<&str>) { + if let Some(at) = v.find("..") { + return ("range", &v[..at], Some(&v[at + 2..])); + } + for (prefix, op) in [(">=", "ge"), ("<=", "le"), (">", "gt"), ("<", "lt")] { + if let Some(rest) = v.strip_prefix(prefix) { + return (op, rest, None); + } + } + ("eq", v, None) +} + +/// `-?\d{1,15}(\.\d{1,15})?`. +fn is_query_number(s: &str) -> bool { + let body = s.strip_prefix('-').unwrap_or(s); + let (int, frac) = match body.split_once('.') { + Some((i, f)) => (i, Some(f)), + None => (body, None), + }; + let digits = |d: &str| (1..=15).contains(&d.len()) && d.bytes().all(|b| b.is_ascii_digit()); + digits(int) && frac.is_none_or(digits) +} + +/// A typed comparison operand. +fn operand(field: &BoardField, s: &str) -> Option { + match field.kind { + FieldType::Num => is_query_number(s) + .then(|| s.parse::().ok()) + .flatten() + .map(Scalar::Num), + FieldType::Date => { + if s.to_lowercase() == "@today" { + Some(Scalar::Text("@today".into())) + } else { + date_days(s).map(|_| Scalar::Text(s.to_string())) + } + } + FieldType::Iter => { + let low = s.to_lowercase(); + if ITER_RELATIVE.contains(&low.as_str()) { + return Some(Scalar::Text(low)); + } + // `3` or `"Iteration 3"`: iteration 3, index 2 + let prefix = format!("{} ", field.name.to_lowercase()); + let n = low.strip_prefix(&prefix).unwrap_or(&low); + let ok = (1..=5).contains(&n.len()) + && !n.starts_with('0') + && n.bytes().all(|b| b.is_ascii_digit()); + ok.then(|| n.parse::().ok()) + .flatten() + .filter(|n| n - 1 <= ITER_INDEX_MAX) + .map(|n| Scalar::from(n - 1)) + } + _ => None, + } +} + +/// A custom-field qualifier's predicate. +fn field_pred(field: &BoardField, value: &str, not: bool) -> Option { + if value.is_empty() { + return None; + } + let pred = |op: &'static str, v: Scalar, v2: Option| QueryPred { + k: "field", + not, + v: Some(v), + f: Some(field.id), + op: Some(op), + v2, + }; + match field.kind { + FieldType::Sel => { + let low = value.to_lowercase(); + let opt = field + .options + .as_deref() + .unwrap_or_default() + .iter() + .find(|o| o.name.to_lowercase() == low)?; + Some(pred("eq", Scalar::from(i64::from(opt.id)), None)) + } + FieldType::Text => (char_len(value) <= TEXT_VALUE_MAX) + .then(|| pred("has", Scalar::Text(value.to_lowercase()), None)), + _ => match comparison(value) { + ("range", a, Some(b)) => { + if a == "*" && b == "*" { + return None; + } + let lo = if a == "*" { + None + } else { + Some(operand(field, a)?) + }; + let hi = if b == "*" { + None + } else { + Some(operand(field, b)?) + }; + match (lo, hi) { + (None, Some(hi)) => Some(pred("le", hi, None)), + (Some(lo), None) => Some(pred("ge", lo, None)), + (Some(lo), Some(hi)) => Some(pred("range", lo, Some(hi))), + (None, None) => None, + } + } + (op, a, _) => operand(field, a).map(|v| pred(op, v, None)), + }, + } +} + +/// Read a board query (§4.4): the web's `parseBoardQuery`, whose comment lists the grammar. +/// `repos` maps the names the query's `repo:` qualifiers type ([`repo_names_of`]) to the +/// repository ids the client resolved them to; one it did not resolve is reported. +#[must_use] +#[allow(clippy::implicit_hasher)] // the caller's resolved names +pub fn parse_board_query( + text: &str, + spec: &BoardSpec, + repos: &HashMap, +) -> BoardQuery { + parse_query(text, spec, false, repos) +} + +/// A source's query (§2.3): [`parse_board_query`] less what depends on the board or the +/// reader rather than the item (`status:`, `no:status`, custom fields, `is:archived`, `@me`), +/// which goes to `unresolved`. Its `repo:` takes a repository id only (the fold reads nothing +/// to resolve a name; a source names its repository by `r` anyway). +#[must_use] +pub fn parse_source_query(text: &str, spec: &BoardSpec) -> BoardQuery { + parse_query(text, spec, true, &HashMap::new()) +} + +/// Whether a predicate reads the board or the reader, not only the item. +fn board_only(p: &QueryPred) -> bool { + match p.k { + "status" | "field" => true, + "no" => p.v_text() == "status" || field_key_id(p.v_text()).is_some(), + "is" => p.v_text() == "archived", + "assignee" | "author" => p.v_text() == "me", + _ => false, + } +} + +fn parse_query( + text: &str, + spec: &BoardSpec, + for_source: bool, + repos: &HashMap, +) -> BoardQuery { + let mut preds = Vec::new(); + let mut free: Vec = Vec::new(); + let mut unresolved = Vec::new(); + let field_by_name: HashMap = spec + .fields + .iter() + .map(|f| (f.name.to_lowercase(), f)) + .collect(); + for tok in tokens(text) { + let Some((key, not, _, value)) = token_parts(&tok).filter(|(key, _, raw, value)| { + !key.is_empty() + && (!value.is_empty() + || QUERY_KEYS.contains(&key.as_str()) + || field_by_name.contains_key(key)) + && !raw.starts_with("//") + }) else { + free.push(tok); + continue; + }; + match qualifier(&key, &value, not, spec, &field_by_name, repos) { + Some(pred) if !(for_source && board_only(&pred)) => preds.push(pred), + _ => unresolved.push(tok), + } + } + BoardQuery { + preds, + text: free.join(" "), + unresolved, + } +} + +fn qualifier( + key: &str, + value: &str, + not: bool, + spec: &BoardSpec, + field_by_name: &HashMap, + repos: &HashMap, +) -> Option { + let low = value.to_lowercase(); + match key { + "is" | "state" => { + let ok = if key == "is" { IS_VALUES } else { STATE_VALUES }; + ok.contains(&low.as_str()) + .then(|| QueryPred::of("is", not, Scalar::Text(low))) + } + "label" => (!value.is_empty() && char_len(value) <= LABEL_MAX) + .then(|| QueryPred::of("label", not, Scalar::Text(value.into()))), + "milestone" => (!value.is_empty() && char_len(value) <= MILESTONE_MAX) + .then(|| QueryPred::of("milestone", not, Scalar::Text(value.into()))), + "assignee" | "author" => { + let k = if key == "author" { + "author" + } else { + "assignee" + }; + person_of(value).map(|who| QueryPred::of(k, not, Scalar::Text(who))) + } + "repo" => { + let id = if is_identifier(value) { + Some(value) + } else { + repos.get(value).map(String::as_str) + }; + id.filter(|id| is_identifier(id)) + .map(|id| QueryPred::of("repo", not, Scalar::Text(id.into()))) + } + "status" => spec + .columns + .iter() + .find(|c| c.name.to_lowercase() == low) + .map(|c| QueryPred::of("status", not, Scalar::from(i64::from(c.id)))), + "no" => { + if ["label", "assignee", "milestone", "status"].contains(&low.as_str()) { + return Some(QueryPred::of("no", not, Scalar::Text(low))); + } + field_by_name + .get(&low) + .map(|f| QueryPred::of("no", not, Scalar::Text(format!("f{}", f.id)))) + } + _ => field_pred(field_by_name.get(key)?, value, not), + } +} + +/// What a query reads besides the item: the viewer (`@me`) and the time (`@today`, +/// `@current`). +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct QueryContext { + /// The viewer's identity id. + pub me: Option, + /// Now, in ms. + pub now: i64, +} + +/// An operand resolved: `@today` to today's date, the relative iterations to indices. +fn resolve_operand(field: &BoardField, v: &Scalar, ctx: &QueryContext) -> Option { + match v.text() { + Some("@today") => Some(Scalar::Text(date_of(ctx.now))), + Some(rel) if ITER_RELATIVE.contains(&rel) => { + // before the first iteration there is no current one, and the next is the first + let cur = iteration_at(field, ctx.now); + let start = field.start.as_deref().and_then(date_days).unwrap_or(0); + let before = ctx.now < start * DAY_MS; + let k = match rel { + "@current" => cur, + "@next" => cur.map(|c| c + 1).or(before.then_some(0)), + _ => cur.filter(|c| *c > 0).map(|c| c - 1), + }; + k.map(Scalar::from) + } + _ => Some(v.clone()), + } +} + +fn compare(x: &Scalar, y: &Scalar) -> Ordering { + match (x, y) { + (Scalar::Num(a), Scalar::Num(b)) => a.partial_cmp(b).unwrap_or(Ordering::Equal), + _ => x.display().cmp(&y.display()), + } +} + +fn field_holds( + p: &QueryPred, + field: &BoardField, + value: Option<&Scalar>, + ctx: &QueryContext, +) -> bool { + let Some(value) = value else { return false }; + let Some(pv) = p.v.as_ref() else { return false }; + if p.op == Some("has") { + return value.display().to_lowercase().contains(&pv.display()); + } + let Some(a) = resolve_operand(field, pv, ctx) else { + return false; + }; + let c = compare(value, &a); + match p.op { + Some("eq") => c == Ordering::Equal, + Some("gt") => c == Ordering::Greater, + Some("ge") => c != Ordering::Less, + Some("lt") => c == Ordering::Less, + Some("le") => c != Ordering::Greater, + Some("range") => { + p.v2.as_ref() + .and_then(|b| resolve_operand(field, b, ctx)) + .is_some_and(|b| c != Ordering::Less && compare(value, &b) != Ordering::Greater) + } + _ => false, + } +} + +/// Whether the item's title and number hold every free-text term (the Issues tab's +/// `matches_text`, without a body). +fn text_matches(text: &str, item: &BoardItem) -> bool { + let title = item.title.to_lowercase(); + let digits = |s: &str| !s.is_empty() && s.bytes().all(|b| b.is_ascii_digit()); + search_terms(text).iter().all(|t| { + let holds = if let Some(n) = t.text.strip_prefix('#').filter(|n| digits(n)) { + n.parse::().ok() == Some(item.number) + } else { + (digits(&t.text) && t.text.parse::().ok() == Some(item.number)) + || title.contains(&t.text) + }; + holds != t.not + }) +} + +fn pred_holds( + p: &QueryPred, + item: &BoardItem, + placement: Option<&Placement>, + spec: &BoardSpec, + ctx: &QueryContext, +) -> bool { + let eqi = |a: &str, b: &str| a.to_lowercase() == b.to_lowercase(); + let v = p.v_text(); + match p.k { + "is" => match v { + "open" => item.state == ItemState::Open, + "closed" => item.state != ItemState::Open, + "merged" => item.state == ItemState::Merged, + "unmerged" => item.state != ItemState::Merged, + "issue" => item.kind == ItemKind::Issue, + "pr" => item.kind == ItemKind::Pr, + _ => placement.is_some_and(|pl| pl.archived.is_some()), + }, + "label" => item.labels.iter().any(|l| eqi(l, v)), + "milestone" => item.milestone.as_deref().is_some_and(|m| eqi(m, v)), + "assignee" | "author" => { + let who = if v == "me" { + ctx.me.as_deref() + } else { + Some(v) + }; + who.is_some_and(|who| { + if p.k == "author" { + item.author == who + } else { + item.assignees.iter().any(|a| a == who) + } + }) + } + "repo" => item.repo_id == v, + "status" => placement.is_some_and(|pl| Some(Scalar::from(i64::from(pl.col))) == p.v), + "no" => match v { + "label" => item.labels.is_empty(), + "assignee" => item.assignees.is_empty(), + "milestone" => item.milestone.is_none(), + "status" => placement.is_some_and(|pl| pl.col == 0), + key => placement + .is_some_and(|pl| field_key_id(key).is_none_or(|id| !pl.fields.contains_key(&id))), + }, + "field" => { + let field = p.f.and_then(|id| spec.field(id)); + match (field, placement) { + (Some(field), Some(pl)) => field_holds(p, field, pl.fields.get(&field.id), ctx), + _ => false, + } + } + _ => false, + } +} + +/// Whether an item (with its placement; none for a source) holds every predicate, each +/// negated by `-`, and the free text. +fn query_holds( + item: &BoardItem, + placement: Option<&Placement>, + spec: &BoardSpec, + query: &BoardQuery, + ctx: &QueryContext, +) -> bool { + query + .preds + .iter() + .all(|p| pred_holds(p, item, placement, spec, ctx) != p.not) + && text_matches(&query.text, item) +} + +/// Whether an item on the board passes `query` (§4.4): on the board, archived exactly when +/// the query has `is:archived`, holding every predicate and the free text. A value the item +/// lacks never matches its qualifier (so `-priority:P0` matches an item with no priority). +#[must_use] +pub fn matches_board_query( + item: &BoardItem, + placement: &Placement, + spec: &BoardSpec, + query: &BoardQuery, + ctx: &QueryContext, +) -> bool { + if !placement.on { + return false; + } + let wants_archived = query + .preds + .iter() + .any(|p| p.k == "is" && p.v_text() == "archived"); + if !wants_archived && placement.archived.is_some() { + return false; + } + query_holds(item, Some(placement), spec, query, ctx) +} + +// --------------------------------------------------------------------------------------------- +// Views: grouping, sorting, totals, progress (§4.1–§4.5) +// --------------------------------------------------------------------------------------------- + +/// An item with its placement, as views take them. +#[derive(Debug, Clone, Copy)] +pub struct BoardRow<'a> { + /// The item. + pub item: &'a BoardItem, + /// Where it shows. + pub placement: &'a Placement, +} + +/// A group: its key (a column id for `status`, 0 for "No status"; an option id; an iteration +/// index; an identity id; a label or milestone name; a repo id; `None` for "No ") and +/// its items. +#[derive(Debug, Clone, PartialEq, Serialize)] +pub struct RowGroup { + /// The key. + pub key: Option, + /// Item ids. + pub items: Vec, +} + +/// A map key for a [`Scalar`]. +fn scalar_key(s: &Scalar) -> String { + match s { + Scalar::Num(x) => format!("n{}", js_number(*x)), + Scalar::Text(t) => format!("s{t}"), + } +} + +/// `rows` grouped by `by` (a view's `group` or `lane` key): the web's `groupRows`, whose +/// comment gives the order. +#[must_use] +pub fn group_rows(rows: &[BoardRow<'_>], by: &str, spec: &BoardSpec, now: i64) -> Vec { + let field = field_of_key(&spec.fields, by); + let keys_of = |r: &BoardRow<'_>| -> Vec> { + let dedup = |v: &[String]| -> Vec> { + let mut seen = HashSet::new(); + v.iter() + .filter(|x| seen.insert(x.as_str())) + .map(|x| Some(Scalar::Text(x.clone()))) + .collect() + }; + match by { + "status" => { + vec![(r.placement.col != 0).then(|| Scalar::from(i64::from(r.placement.col)))] + } + "assignee" if !r.item.assignees.is_empty() => dedup(&r.item.assignees), + "label" if !r.item.labels.is_empty() => dedup(&r.item.labels), + "assignee" | "label" => vec![None], + "milestone" => vec![r.item.milestone.clone().map(Scalar::Text)], + "repo" => vec![Some(Scalar::Text(r.item.repo_id.clone()))], + _ => vec![field.and_then(|f| r.placement.fields.get(&f.id).cloned())], + } + }; + let order: Vec = if by == "status" { + spec.columns + .iter() + .map(|c| Scalar::from(i64::from(c.id))) + .collect() + } else if field.is_some_and(|f| f.kind == FieldType::Sel) { + field + .and_then(|f| f.options.as_deref()) + .unwrap_or_default() + .iter() + .map(|o| Scalar::from(i64::from(o.id))) + .collect() + } else if field.is_some_and(|f| f.kind == FieldType::Iter) + || ["assignee", "label", "milestone", "repo"].contains(&by) + { + let mut present: Vec = Vec::new(); + let mut seen = HashSet::new(); + let mut add = |k: Scalar| { + if seen.insert(scalar_key(&k)) { + present.push(k); + } + }; + for r in rows { + for k in keys_of(r).into_iter().flatten() { + add(k); + } + } + if let Some(f) = field { + if let Some(cur) = iteration_at(f, now) { + add(Scalar::from(cur)); + } + } + present.sort_by(compare); + present + } else { + return vec![RowGroup { + key: None, + items: rows.iter().map(|r| r.item.id.clone()).collect(), + }]; + }; + let index: HashMap = order + .iter() + .enumerate() + .map(|(i, k)| (scalar_key(k), i)) + .collect(); + let mut empty = Vec::new(); + let mut groups: Vec> = vec![Vec::new(); order.len()]; + for r in rows { + for k in keys_of(r) { + match k { + None => empty.push(r.item.id.clone()), + Some(k) => { + if let Some(&i) = index.get(&scalar_key(&k)) { + groups[i].push(r.item.id.clone()); + } + } + } + } + } + let mut out = Vec::new(); + if !empty.is_empty() { + out.push(RowGroup { + key: (by == "status").then(|| Scalar::from(0)), + items: empty, + }); + } + out.extend(order.into_iter().zip(groups).map(|(k, items)| RowGroup { + key: Some(k), + items, + })); + out +} + +/// A row's sort value under `key` (no `-`); `None` when it has none (sorted last). +fn sort_value(r: &BoardRow<'_>, key: &str, spec: &BoardSpec) -> Option { + let index = |i: usize| Scalar::from(i64::try_from(i).unwrap_or(i64::MAX)); + match key { + "title" => Some(Scalar::Text(r.item.title.to_lowercase())), + #[allow(clippy::cast_precision_loss)] // issue numbers: far below 2^53 + "number" => Some(Scalar::Num(r.item.number as f64)), + "created" => Some(Scalar::from(r.item.created_at)), + "status" => spec.column_index(r.placement.col).map(index), + // by id, as `group_rows` orders repositories: the label (`item.repo`) is each client's own + "repo" => Some(Scalar::Text(r.item.repo_id.clone())), + "author" => Some(Scalar::Text(r.item.author.clone())), + "milestone" => r + .item + .milestone + .as_ref() + .map(|m| Scalar::Text(m.to_lowercase())), + _ => { + let field = field_of_key(&spec.fields, key)?; + let v = r.placement.fields.get(&field.id)?; + Some(match field.kind { + FieldType::Sel => field + .options + .as_deref() + .unwrap_or_default() + .iter() + .position(|o| *v == Scalar::from(i64::from(o.id))) + .map_or(Scalar::from(-1), index), + FieldType::Text => Scalar::Text(v.display().to_lowercase()), + _ => v.clone(), + }) + } + } +} + +/// `rows` in a view's `sort` (`None` or `rank`: the column order, §2.6): by the key, `-` for +/// descending; rows without a value last in both directions; ties by (rank, item id). +#[must_use] +pub fn sort_rows<'a>( + rows: &[BoardRow<'a>], + sort: Option<&str>, + spec: &BoardSpec, +) -> Vec> { + let desc = sort.is_some_and(|s| s.starts_with('-')); + let key = sort.map_or("rank", |s| s.strip_prefix('-').unwrap_or(s)); + let tie = |a: &BoardRow<'_>, b: &BoardRow<'_>| { + by_rank( + &a.placement.rank, + &a.placement.id, + &b.placement.rank, + &b.placement.id, + ) + }; + let mut out = rows.to_vec(); + if key == "rank" { + out.sort_by(|a, b| if desc { tie(b, a) } else { tie(a, b) }); + return out; + } + out.sort_by( + |a, b| match (sort_value(a, key, spec), sort_value(b, key, spec)) { + (None, None) => tie(a, b), + (None, Some(_)) => Ordering::Greater, + (Some(_), None) => Ordering::Less, + (Some(x), Some(y)) => { + let c = compare(&x, &y); + let c = if desc { c.reverse() } else { c }; + c.then_with(|| tie(a, b)) + } + }, + ); + out +} + +/// The number field a view sums (§4.5): the first `num` field of its `cols`, or with no +/// `cols` the spec's first. +#[must_use] +pub fn sum_field_of(spec: &BoardSpec, view: Option<&BoardView>) -> Option { + let keys: Vec = view + .and_then(|v| v.cols.clone()) + .unwrap_or_else(|| spec.fields.iter().map(|f| format!("f{}", f.id)).collect()); + keys.iter() + .filter_map(|k| field_of_key(&spec.fields, k)) + .find(|f| f.kind == FieldType::Num) + .map(|f| f.id) +} + +/// A group's totals: its item count and the sum of a number field (`None` with none). +#[derive(Debug, Clone, PartialEq, Serialize)] +pub struct Totals { + /// Items. + pub count: usize, + /// The sum. + pub sum: Option, +} + +/// `rows`' count and the sum of number field `sum_field`'s values (in `rows`' order). +#[must_use] +pub fn totals(rows: &[BoardRow<'_>], sum_field: Option) -> Totals { + let sum = sum_field.map(|id| { + let mut sum = 0.0; + for r in rows { + if let Some(Scalar::Num(x)) = r.placement.fields.get(&id) { + sum += x; + } + } + Scalar::Num(sum) + }); + Totals { + count: rows.len(), + sum, + } +} + +/// A status column's totals (§4.5) and its WIP limit; `over` when the count passes it. +#[derive(Debug, Clone, PartialEq, Serialize)] +pub struct ColumnTotals { + /// The column id (0: "No status"). + pub id: u8, + /// Items. + pub count: usize, + /// The sum. + pub sum: Option, + /// The WIP limit. + pub wip: Option, + /// Over the WIP limit. + pub over: bool, +} + +/// Every status column's totals for `rows` (as [`group_rows`] by `status` groups them). +#[must_use] +pub fn column_totals( + rows: &[BoardRow<'_>], + spec: &BoardSpec, + sum_field: Option, +) -> Vec { + let by_id: HashMap<&str, &BoardRow<'_>> = + rows.iter().map(|r| (r.item.id.as_str(), r)).collect(); + group_rows(rows, "status", spec, 0) + .into_iter() + .map(|g| { + let in_group: Vec> = g + .items + .iter() + .filter_map(|id| by_id.get(id.as_str()).map(|r| **r)) + .collect(); + let t = totals(&in_group, sum_field); + #[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)] // column ids + let id = g.key.as_ref().and_then(Scalar::num).unwrap_or(0.0) as u8; + let wip = spec.columns.iter().find(|c| c.id == id).and_then(|c| c.wip); + ColumnTotals { + id, + count: t.count, + sum: t.sum, + wip, + over: wip.is_some_and(|w| t.count > usize::from(w)), + } + }) + .collect() +} + +/// An iteration's progress (§4.5): items and points, all and done. +#[derive(Debug, Clone, PartialEq, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct IterationProgress { + /// Items in the iteration. + pub total: usize, + /// Of them done. + pub done: usize, + /// Their points (`None` without a points field). + pub points: Option, + /// The done ones' points. + pub done_points: Option, +} + +/// Progress of iteration `k` of field `field_id` over `rows`: the rows whose value is `k`; +/// done is in the Done column, or closed or merged. +#[must_use] +pub fn iteration_progress( + rows: &[BoardRow<'_>], + spec: &BoardSpec, + field_id: u8, + k: i64, + points_field: Option, +) -> IterationProgress { + let want = Scalar::from(k); + let in_iter: Vec> = rows + .iter() + .filter(|r| r.placement.fields.get(&field_id) == Some(&want)) + .copied() + .collect(); + let done: Vec> = in_iter + .iter() + .filter(|r| { + (spec.done != 0 && r.placement.col == spec.done) || r.item.state != ItemState::Open + }) + .copied() + .collect(); + let all = totals(&in_iter, points_field); + let fin = totals(&done, points_field); + IterationProgress { + total: all.count, + done: fin.count, + points: all.sum, + done_points: fin.sum, + } +} + +#[cfg(test)] +mod tests; diff --git a/crates/forge-core/src/rules/boards/tests.rs b/crates/forge-core/src/rules/boards/tests.rs new file mode 100644 index 000000000..1e79fdfef --- /dev/null +++ b/crates/forge-core/src/rules/boards/tests.rs @@ -0,0 +1,444 @@ +use serde_json::{json, Value}; + +use super::*; + +/// The vector's spec (a JSON object), read as `board.spec` would be. +fn spec_of(v: &Value) -> BoardSpec { + parse_spec(&serde_json::to_string(v).unwrap()).expect("vector spec parses") +} + +fn de(v: &Value) -> T { + serde_json::from_value(v.clone()).unwrap() +} + +fn rank_json(r: Result) -> Value { + match r { + Ok(rank) => json!({ "rank": rank }), + Err(e) => json!({ "error": e.as_str() }), + } +} + +fn opt_str(v: &Value) -> Option { + v.as_str().map(str::to_string) +} + +/// The vector's `repos`: the names its `repo:` qualifiers type, resolved to repository ids (as +/// a client resolves them before parsing); none when absent. +fn repos_of(inp: &Value) -> HashMap { + inp["repos"] + .as_object() + .map(|m| { + m.iter() + .map(|(k, v)| (k.clone(), v.as_str().unwrap().to_string())) + .collect() + }) + .unwrap_or_default() +} + +/// The fold a vector describes, and its spec and items. +fn fold_of(inp: &Value) -> (BoardSpec, Vec, BoardFold) { + let spec = spec_of(&inp["spec"]); + let items: Vec = de(&inp["items"]); + let cards: Vec = de(&inp["cards"]); + let fold = fold_board( + &spec, + inp["home"].as_str().unwrap(), + &items, + &cards, + inp["now"].as_i64().unwrap(), + ); + (spec, items, fold) +} + +/// The rows a view vector's query (`q`) keeps, in input order. +fn rows_of<'a>( + inp: &Value, + spec: &BoardSpec, + items: &'a [BoardItem], + fold: &'a BoardFold, +) -> Vec> { + let query = parse_board_query(inp["q"].as_str().unwrap_or(""), spec, &repos_of(inp)); + let ctx = QueryContext { + me: opt_str(&inp["me"]), + now: inp["now"].as_i64().unwrap(), + }; + items + .iter() + .zip(&fold.items) + .map(|(item, placement)| BoardRow { item, placement }) + .filter(|r| matches_board_query(r.item, r.placement, spec, &query, &ctx)) + .collect() +} + +#[allow(clippy::too_many_lines)] // one arm per case and op +fn run(case: &str, inp: &Value) -> Value { + let op = inp["op"].as_str().unwrap(); + match (case, op) { + ("board_spec", "parse") => inp["cases"] + .as_array() + .unwrap() + .iter() + .map(|c| match parse_spec(c["json"].as_str().unwrap()) { + Ok(spec) => json!({ "name": c["name"], "json": serialize_spec(&spec).unwrap() }), + Err(e) => json!({ "name": c["name"], "error": e.as_str() }), + }) + .collect(), + ("board_spec", "default") => { + let spec = default_spec(inp["home"].as_str().unwrap(), inp["now"].as_i64().unwrap()); + json!({ "json": serialize_spec(&spec).unwrap() }) + } + ("board_spec", "values") => { + let spec = spec_of(&inp["spec"]); + let values = parse_field_values(inp["f"].as_str(), &spec); + match serialize_field_values(&values, &spec) { + Some(j) => json!({ "values": values, "json": j }), + None => json!({ "values": values, "error": "size" }), + } + } + ("board_rank", "between") => inp["pairs"] + .as_array() + .unwrap() + .iter() + .map(|p| rank_between(p[0].as_str().unwrap_or(""), p[1].as_str().unwrap_or(""))) + .map(rank_json) + .collect(), + ("board_rank", "top") => inp["firsts"] + .as_array() + .unwrap() + .iter() + .map(|f| rank_json(top_rank(f.as_str()))) + .collect(), + ("board_rank", "bottom") => inp["lasts"] + .as_array() + .unwrap() + .iter() + .map(|l| rank_json(bottom_rank(l.as_str()))) + .collect(), + ("board_rank", "implicit") => inp["items"] + .as_array() + .unwrap() + .iter() + .map(|i| { + json!(implicit_rank_of( + i["createdAt"].as_i64().unwrap(), + i["id"].as_str().unwrap() + )) + }) + .collect(), + ("board_rank", "rerank") => match rerank(inp["n"].as_u64().unwrap()) { + Ok(ranks) => json!({ "ranks": ranks }), + Err(e) => json!({ "error": e.as_str() }), + }, + ("board_fold", "fold") => serde_json::to_value(fold_of(inp).2).unwrap(), + ("board_fold", "boards") => { + let docs: Vec = de(&inp["docs"]); + newest_boards(&docs, inp["withDeleted"].as_bool().unwrap_or(false)) + .iter() + .map(|d| json!({ "key": d.key, "id": d.id, "state": d.state })) + .collect() + } + ("board_query", "parse") => { + let spec = spec_of(&inp["spec"]); + serde_json::to_value(parse_board_query( + inp["text"].as_str().unwrap(), + &spec, + &repos_of(inp), + )) + .unwrap() + } + ("board_query", "names") => inp["texts"] + .as_array() + .unwrap() + .iter() + .map(|t| json!(repo_names_of(t.as_str().unwrap()))) + .collect(), + ("board_query", "source") => { + let spec = spec_of(&inp["spec"]); + serde_json::to_value(parse_source_query(inp["text"].as_str().unwrap(), &spec)).unwrap() + } + ("board_query", "match") => { + let (spec, items, fold) = fold_of(inp); + inp["texts"] + .as_array() + .unwrap() + .iter() + .map(|text| { + let mut q = inp.clone(); + q["q"] = text.clone(); + rows_of(&q, &spec, &items, &fold) + .iter() + .map(|r| json!(r.item.id)) + .collect::() + }) + .collect() + } + ("board_iteration", "at" | "range") => { + let spec = spec_of(&inp["spec"]); + let field = spec + .field(u8::try_from(inp["field"].as_u64().unwrap()).unwrap()) + .unwrap(); + if op == "at" { + inp["dates"] + .as_array() + .unwrap() + .iter() + .map(|d| json!(iteration_at(field, d.as_i64().unwrap()))) + .collect() + } else { + inp["ks"] + .as_array() + .unwrap() + .iter() + .map(|k| { + serde_json::to_value(iteration_range(field, k.as_i64().unwrap())).unwrap() + }) + .collect() + } + } + ("board_view", _) => { + let (spec, items, fold) = fold_of(inp); + let rows = rows_of(inp, &spec, &items, &fold); + let field_id = |k: &str| inp[k].as_u64().map(|x| u8::try_from(x).unwrap()); + match op { + "group" => serde_json::to_value(group_rows( + &rows, + inp["by"].as_str().unwrap(), + &spec, + inp["now"].as_i64().unwrap(), + )) + .unwrap(), + "sort" => inp["sorts"] + .as_array() + .unwrap() + .iter() + .map(|sort| { + sort_rows(&rows, sort.as_str(), &spec) + .iter() + .map(|r| json!(r.item.id)) + .collect::() + }) + .collect(), + "totals" => { + let view = + field_id("view").and_then(|id| spec.views.iter().find(|v| v.id == id)); + serde_json::to_value(column_totals(&rows, &spec, sum_field_of(&spec, view))) + .unwrap() + } + "progress" => serde_json::to_value(iteration_progress( + &rows, + &spec, + field_id("field").unwrap(), + inp["k"].as_i64().unwrap(), + field_id("points"), + )) + .unwrap(), + other => panic!("unknown board_view op `{other}`"), + } + } + _ => panic!("unknown board vector `{case}` op `{op}`"), + } +} + +/// Every `board_*__*.json` vector, the same as forge-web `lib/rules/boards.conformance.test.ts` +/// runs. +#[test] +fn board_vectors() { + let dir = concat!(env!("CARGO_MANIFEST_DIR"), "/../../forge-contracts/vectors"); + let mut files: Vec<_> = std::fs::read_dir(dir) + .unwrap() + .map(|e| e.unwrap().path()) + .filter(|p| { + p.file_name() + .unwrap() + .to_string_lossy() + .starts_with(VECTOR_CASE_PREFIX) + }) + .collect(); + files.sort(); + let mut cases = std::collections::BTreeSet::new(); + for path in &files { + let v: Value = serde_json::from_slice(&std::fs::read(path).unwrap()).unwrap(); + let case = v["case"].as_str().unwrap(); + let name = path.file_name().unwrap().to_string_lossy(); + assert!( + name.starts_with(&format!("{case}__")), + "{name}: file is __.json" + ); + cases.insert(case.to_string()); + let got = run(case, &v["input"]); + assert_eq!(got, v["expected"], "vector {name}"); + } + for c in [ + "board_rank", + "board_spec", + "board_fold", + "board_query", + "board_iteration", + "board_view", + ] { + assert!(cases.contains(c), "no {c} vectors"); + } + assert!(files.len() >= 30, "ran {} board vectors", files.len()); + println!("board_vectors: {} green", files.len()); +} + +/// A deterministic PRNG (splitmix64), the same as `boards.test.ts` uses. +struct Rng(u64); + +impl Rng { + fn next(&mut self) -> u64 { + self.0 = self.0.wrapping_add(0x9e37_79b9_7f4a_7c15); + let mut z = self.0; + z = (z ^ (z >> 30)).wrapping_mul(0xbf58_476d_1ce4_e5b9); + z = (z ^ (z >> 27)).wrapping_mul(0x94d0_49bb_1331_11eb); + z ^ (z >> 31) + } + + fn below(&mut self, n: u64) -> usize { + usize::try_from(self.next() % n).unwrap() + } + + /// 0–`max` rank digits, biased to `0`, `1`, `y`, `z` and short strings (the edges). + fn digits(&mut self, max: u64) -> String { + let len = self.below(max + 1); + (0..len) + .map(|_| match self.below(4) { + 0 => char::from(b"01yz"[self.below(4)]), + _ => char::from(RANK_DIGITS[self.below(62)]), + }) + .collect() + } +} + +/// Whether nothing lies strictly between `a` < `b`: `b` is `a` and only `0`s. +fn nothing_between(a: &str, b: &str) -> bool { + b.len() > a.len() && b.starts_with(a) && b[a.len()..].bytes().all(|c| c == b'0') +} + +fn check_between(a: &str, b: &str) { + match rank_between(a, b) { + Ok(r) => { + assert!(a < r.as_str(), "{a:?} < {r:?}"); + assert!(b.is_empty() || r.as_str() < b, "{r:?} < {b:?}"); + assert!(is_explicit_rank(&r), "{r:?} is an explicit rank"); + assert!(r.len() <= a.len().max(b.len()) + 1, "{r:?} is short"); + } + Err(e) => { + let too_long = a.len().max(b.len()) >= RANK_MAX; + assert!( + e == RankError::Rerank && (nothing_between(a, b) || too_long), + "{a:?} {b:?}: {e:?}" + ); + } + } +} + +#[test] +fn rank_between_is_strictly_between() { + let mut rng = Rng(0x00b0_a2d5); + for _ in 0..20_000 { + let (x, y) = (rng.digits(6), rng.digits(6)); + // half the pairs share a prefix, so prefix relations (`V` / `V1` / `V10`) are common + let (x, y) = if rng.below(2) == 0 { + let p = rng.digits(4); + (format!("{p}{x}"), format!("{p}{y}")) + } else { + (x, y) + }; + match x.cmp(&y) { + Ordering::Less => check_between(&x, &y), + Ordering::Greater => check_between(&y, &x), + Ordering::Equal if x.is_empty() => assert_eq!(rank_between("", "").as_deref(), Ok("V")), + Ordering::Equal => assert_eq!(rank_between(&x, &y), Err(RankError::Rerank)), + } + check_between(&x, ""); + if !x.is_empty() { + check_between("", &x); + } + } + // the pool: implicit ranks may end in `0` + for (a, b) in [ + ("V", "V0"), + ("V1", "V10"), + ("V1", "V100"), + ("V10", "V1000"), + ("", "0"), + ("", "00"), + ] { + assert_eq!(rank_between(a, b), Err(RankError::Rerank), "{a} {b}"); + } + assert_eq!(rank_between("V1", "V101").as_deref(), Ok("V100V")); + assert_eq!(rank_between("V", "V01").as_deref(), Ok("V00V")); +} + +#[test] +fn repeated_drops_into_one_gap_end_in_rerank() { + // always dropping just below the last drop: each halves the gap + let (mut lo, mut hi) = (String::new(), "V".to_string()); + let mut drops = 0; + while let Ok(r) = rank_between(&lo, &hi) { + hi = r; + drops += 1; + assert!(drops < 1000); + } + assert!((300..=400).contains(&drops), "{drops} drops"); + // and just above it + hi = String::new(); + lo = "V".to_string(); + drops = 0; + while let Ok(r) = rank_between(&lo, &hi) { + lo = r; + drops += 1; + assert!(drops < 20_000); + } + assert!(drops > 300, "{drops} drops"); +} + +#[test] +fn rerank_spreads_below_the_pool() { + for n in [0_u64, 1, 2, 3, 30, 31, 100, 1921, 1922, 5000] { + let ranks = rerank(n).unwrap(); + assert_eq!(ranks.len(), usize::try_from(n).unwrap()); + for w in ranks.windows(2) { + assert!(w[0] < w[1]); + assert!(rank_between(&w[0], &w[1]).is_ok()); + } + assert!(ranks + .iter() + .all(|r| is_explicit_rank(r) && r.as_str() < "V")); + } + assert_eq!(rerank(RERANK_MAX + 1), Err(RankError::Invalid)); +} + +#[test] +fn spec_round_trips_and_defaults_fit() { + let spec = default_spec( + "4tJ7mVo5yJm4b6rKZ2SRsG6YqfJHFDLC2kUwD3nAhZ7b", + 1_761_782_400_000, + ); + let json = serialize_spec(&spec).unwrap(); + assert_eq!(parse_spec(&json).unwrap(), spec); + assert_eq!(serialize_spec(&parse_spec(&json).unwrap()).unwrap(), json); + assert!(json.len() <= SPEC_MAX_BYTES); +} + +#[test] +fn dates_and_mondays() { + assert_eq!(date_days("1970-01-01"), Some(0)); + assert_eq!(date_days("2024-02-29"), Some(19_782)); + assert_eq!(date_days("2023-02-29"), None); + assert_eq!(civil_from_days(19_782), "2024-02-29"); + assert_eq!(monday_of(0), "1969-12-29"); + // 2026-10-27 is a Tuesday + assert_eq!( + monday_of(date_days("2026-10-27").unwrap() * DAY_MS + 5), + "2026-10-26" + ); + assert_eq!( + monday_of(date_days("2026-10-26").unwrap() * DAY_MS), + "2026-10-26" + ); + for d in [-719_162_i64, -700_000, -1, 0, 59, 60, 10_000, 2_932_896] { + assert_eq!(date_days(&civil_from_days(d)), Some(d)); + } +} diff --git a/docs/contracts/forge-v2.md b/docs/contracts/forge-v2.md index ee6fdcfec..b1f0f552e 100644 --- a/docs/contracts/forge-v2.md +++ b/docs/contracts/forge-v2.md @@ -126,6 +126,15 @@ The mainnet forge-core also gains `pushGrant` (B1, §9.1): a maintainer's grant Size: forge-meta serializes to 7,684 B (6,870 B without it), its create transition to 7,790 B (6,976 B), which leaves 12,690 B of room; the fee schedule's registration fee for the contract goes from 0.36 to 0.39 DASH (one more type and one more index; the per-byte part is not in that figure). **Estimated fees** (not measured on Forge; scaled from Yappr's sakura measurements of the same document shape, to be re-measured by the live test): a first entry about 46 to 50 M credits (about 0.0005 DASH), a later entry about 28 to 31 M, a re-seal about 2 to 3 M, a delete refunds about 23 to 35 M, and a sign-in reads only, so it is free. Forge's 256 B ciphertext is 80 to 160 B larger than Yappr's, which adds about 2 to 4 M credits at 27,400 credits per byte ([economics.md](../economics.md)). All of it comes out of the signed-in key's budget. +**`board` and `card` (UPDATE-3, boards; [docs/design/boards.md](../design/boards.md) §3).** Two more types no other layout has: a board's definition, and a member's placement of one issue or PR on it. `build.py` defines them in forge-community (flag `boards`, in `UPDATE3_FLAGS`) and `META_TYPES` moves them to forge-meta, built with the four-contract layout only, as `vaultEntry`. Their gate is `label`'s: `ownerRefersTo` a forge-core `maintainer` of `repoId`, or a `writer` with `where {"role": "r"}`. A `deletableDocument` found by `findBy` is asked again on every replace (book `contract-keywords/owner-refers-to.md` "On replace"), so a removed member cannot touch their old documents and a role change holds from the next write. `card.item` refers to forge-collab's `issue` or `patch` (`FORGE_COLLAB_CONTRACT_ID`, no `where`: any repository's item), so forge-meta now names forge-collab as well as forge-core. Both are mutable and **never deleted** (`canBeDeleted: false`), one document per member: a member's later write replaces their own, and readers take the newest across members by (`$updatedAt`, `$id`). A delete would silently bring the previous member's document back, which no poll of `$updatedAt` sees, so `state` 2 stands for it. Every index key and both timestamps are `required` (an unrequired `$updatedAt` is never recorded, and a unique index holds no document that lacks a key part). No rule or total of another type reads them, and protocol 14 lets an update add them (new types with their own indexes, §9.1). + +| Type | Gate (create) | Mutable | Deletable | Notes | +|---|---|---|---|---| +| `board` | M or W1 (`r` 1, `rClaim` `r = 1`) | yes; `repoId`, `key` immutable | **no** (`state` 2 is the delete) | `key` u32 1–4294967295, the board (random, chosen at creation); `name` 1–63 characters, ≤ 252 B, a visible character (`TITLE`); `spec` ≤ 4,096 B, the definition (JSON `v: 1`, boards.md §2); `state` 0 open, 1 closed, 2 deleted; `enc` 29–5,120 B (its own bound, inline: `$defs.enc` is label's 1,536 B) with `epoch` (`dependentRequired`); a private repo's clients seal `name` and `spec` together in it (a client rule: nothing at consensus ties `enc` to the repo's visibility, as on `label`). `noPlain`: with `enc`, neither `name` nor `spec`; `hasName`: without `enc`, both. Unique `byKey (repoId, key, $ownerId)`; its `repoId` prefix lists a repo's boards. A writer may close or delete a maintainer's board, as with labels (the newest wins) | +| `card` | M or W2 (`r` 1..2, `rClaim`) | yes; `repoId`, `board`, `item` immutable | **no** (`state` 2 is "removed") | `board` u32 1–4294967295 (the board's key); `item` → collab `issue` or `patch`, any repository, required, so a card always names an item; `col` 0–255 (0 none); `rank` 1–63 characters, `^[0-9A-Za-z]*[1-9A-Za-z]$` (base-62, never ending in `0`, boards.md §2.6); `f` ≤ 2,048 B (JSON field values); `state` 0 active, 1 archived, 2 removed, plaintext in every repo; `enc` 29–2,560 B with `epoch` (`dependentRequired`); a private repo's clients seal `col`, `rank` and `f` in it (a client rule, as on `board`), and `noPlain` refuses them in plaintext beside `enc`. Unique `onItem (item, repoId, board, $ownerId)` (one card per member, item and board; its `item` prefix answers "which boards is this on") and `recent (repoId, board, $updatedAt)` (load a board, and poll it for what changed since) | + +Fixed by this registration, since an update can never add an `ownerRefersTo` operand or a reference: only the home repository's members place cards (a member of the item's repository who is not one of the home repo's cannot), a card always names an issue or a PR, and triage defines no board. With `mainnet_pinned_gates` each claim is restated as a rule (`rClaim`), so an update raising `r`'s maximum opens nothing. Size: forge-meta serializes to 10,842 B (7,684 B without them), its create transition to 10,948 B, which leaves 9,532 B of room; the fee schedule's registration fee for the contract goes from 0.39 to 0.46 DASH (two more types, three more indexes). A three-contract network has neither (the clients' layout answers "no contract holds it"). + A devnet may run the three-contract set (devnet sakura did until it moved to the four-contract set on 2026-10-17), and clients take the layout from the deployment record: `v2.forgeMeta` present means four contracts, and the seven types are read and written there; absent, they stay in their old homes. One build serves both (phase M-B: `forge-core::layout` `ForgeIds::contract_of` and `home`, forge-web `lib/layout.ts` `contractKindOfType` and `lib/repo/source.ts` `contractOf`, the seed scripts' `contractOn`). The cost previews follow: a signer's first write to forge-meta pays its contract nonce even when it has written the type's old home, and a key bound to forge-meta alone is a wallet grant of its own ("labels, topics and profiles"). Shared shapes (`id`, `hid`, `oid`, `h32`, `refName`, `branch`, `title`, `body`, `enc`, `vis`, `member`, …) are in `schemaDefs` and referenced with `$ref`. A document type may use each `$defs` entry **once**: rs-dpp's depth walker treats a second `$ref` to the same definition in one type as a cycle (`InvalidJsonSchemaRefError`). That is why `packHash` uses `hid`, an identical copy of `id`. The same goes for the `integer` shape of a key id named by `encryptedFor` or `keyIdProperty`, which must be inline (the parser's `is_key_id_schema` resolves `$ref` against the document schema, which has no `$defs`). Repeats are inlined for these reasons. Every `enc` is at least 29 bytes (INV-11: the smallest envelope). @@ -734,7 +743,7 @@ cargo +1.98.1 run -q --locked --manifest-path tools/contract-validate/Cargo.toml - Results go to the `v2` section of `deployments/.json` (`devnet-.json` for a devnet). Each step's nonce (masked to its low 40 bits, as rs-dpp does), contract id, group id derived from that same nonce, and pre-broadcast balance are written before broadcasting. A rerun that finds the contract on chain completes the record (status, cost, owner) rather than skipping it; one whose reserved nonce never landed takes the chain's next nonce and re-derives both ids from it. It never registers a second copy unless told to. Each record also carries `schemaHash`, the sha256 of the schema JSON (after placeholder substitution, compactly re-serialized) it was registered from; a rerun that finds a recorded contract whose hash differs from the current schema warns and leaves it as is. A dry run's forge-core step is not checked against a leftover record. - `--force-new` without `--only` supersedes the set when the recorded forge-core was registered from a different schema: forge-core's record moves to `v2.forgeCoreSuperseded`, the group to `v2.contractGroupSuperseded`, forge-collab and forge-community (whose schemas name forge-core's id) to `v2.forgeCollabSuperseded` / `v2.forgeCommunitySuperseded`, and a new forge-core (registering a new group), forge-collab and forge-community are registered. A rerun after success registers nothing. - `--only collab` / `--only community` registers that contract alone, against the forge-core and group already recorded and found on chain; it never registers forge-core or the other one. With `--force-new --same-group` it registers a new one when the recorded one is registered from a different schema (its `schemaHash` differs, or it predates the field): the old record moves to `v2.forgeCollabSuperseded` (or `v2.forgeCommunitySuperseded`), and the new one takes the next nonce and so a new id. A recorded contract from the current schema, or one still `broadcasting` (an interrupted run, which is completed or retried instead), is never superseded, so rerunning the same command registers nothing. This is how a schema change the update rules refuse ships. Documents written under the old contract stay under its id. -- **forge-meta** (four-contract sets, §2): registered fourth, after forge-community, with forge-core's id substituted for `FORGE_CORE_CONTRACT_ID`; its create transition enrols it in the group, whose description then names all four ("Dash Forge v2: forge-core, forge-collab, forge-community and forge-meta"; `tools/contract-validate` sizes the same string). `--only meta` registers it alone against the recorded forge-core and group, and `--update meta` updates it in place. Its record is `v2.forgeMeta`. `--self-test --contracts ` checks that forge-meta names forge-core and that nothing registered before it names forge-meta. +- **forge-meta** (four-contract sets, §2): registered fourth, after forge-community, with forge-core's id substituted for `FORGE_CORE_CONTRACT_ID` and, since UPDATE-3 (`card.item`), forge-collab's for `FORGE_COLLAB_CONTRACT_ID`; its create transition enrols it in the group, whose description then names all four ("Dash Forge v2: forge-core, forge-collab, forge-community and forge-meta"; `tools/contract-validate` sizes the same string). `--only meta` registers it alone against the recorded forge-core and group, and `--update meta` updates it in place. Its record is `v2.forgeMeta`. `--self-test --contracts ` checks that forge-meta names forge-core (and forge-collab, when it has cards) and that nothing registered before it names forge-meta. - **Scratch sets.** `--contracts ` registers the JSON in `` instead of `forge-contracts/contracts`, and then needs `--record `: the deployment record the run reads and writes. No file under `forge-contracts/deployments/` (any network's record, the snapshots under `deployments/contracts/`) is accepted as a `--record`, compared by real path and without case; a scratch record that names the network's own forge-core or contract group is refused, and a contract in it registered from another schema stops the run instead of being reused. So a scratch run (phase M-C's throwaway set) never touches or extends the live deployment or the web's snapshot. Without `--addresses` it takes the DAPI addresses from the scratch record, else (read only) from the network's record. - **Named sets and the live testnet/mainnet record.** `--set devnet` (the default on a devnet) is `forge-contracts/contracts`, `--set mainnet` the committed four-contract set `forge-contracts/contracts/mainnet`; testnet and mainnet always need `--set mainnet`, and `--set` excludes `--contracts`. A record keeps the set it was registered from (`v2.contractsSet`; an older record is inferred: a forge-meta means `mainnet`, else `devnet`), and a run naming another set is refused, so a four-contract record can never be updated from the three-contract files. On a devnet, `--force-new` without `--only` moves a record to the named set instead: every recorded contract and the group are superseded and a new set is registered in a new group, with the ledger kept (devnet sakura moved to `--set mainnet` this way on 2026-10-17). `--set mainnet --record ` registers the committed set as a scratch rehearsal. Registering into the live testnet or mainnet record refuses, before anything is broadcast, unless the set's files match git HEAD, HEAD is on a branch of origin (so the recorded commit can be fetched), `build.py --check` passes, `--expect-sha256 ` matches every file of the set (sha256sum lines; `--print-sha256`, and every `--dry-run`, print them), every create transition leaves at least 2,000 B under 20,480 B (D44), and the chain id is proved (a DPNS proof that agrees with the node's status) and is the network's (`dash-testnet-` or `evo1`, dashmate's genesis ids); a preflight pass sizes all of them first. A devnet only warns. The set's files are read once, so the sums checked and recorded are of the bytes registered. Testnet and mainnet are reached by SDK discovery only (`--addresses` is refused), and `--devnet-name` is lower-case letters, digits and dashes, so a devnet run never names another network's record. `--force-new` there also needs `--abandon-live-set `: it supersedes the set every client reads. A record of another chain (`chainId`) stops the run; `--replay` then registers the same ids again ("Same-id restore after a Platform reset" below), or `--force-new --abandon-live-set` supersedes every recorded contract and archives the old ledger in `v2.nonceLedgerSuperseded`. - **What the record keeps.** Beside the ids: `network` and `chainId`; per contract `sourceFile`, `sourceSha256` (the file bytes the owner signed), `gitCommit` and `gitCommitPushed`, `registeredSchemaHash` (never changed by an update), `documentsHash` (sha256 of the documentSchemas and schemaDefs with sorted keys, comparable with a fetched contract), `transitionSha256` (the signed transition's bytes; an update records its own), `roomBytes` and `provedAt` (the block metadata of the first proof after confirmation, an upper bound on the registration block: evo-sdk's wait result carries no height); `v2.contractGroup.admins` (must be empty: clients refuse a group with admins, rule 1) and `description`; `v2.deployer` (`identityId`, `assetLockTxid`, `createdAtHeight` from `--deployer-created-height`; a run with another deployer moves the old block to `v2.deployerSuperseded`); and `v2.nonceLedger`, every transition the deployer signed, in order (a create by identity nonce, an update by identity-contract nonce), written before its broadcast and flipped to `registered` / `updated`. A settled entry is never rewritten. A reservation that never landed and whose nonce went elsewhere is `abandoned`. If the chain's identity nonce is past the ledger's last, something else signed with the deployer and the next create stops until `--acknowledge-nonce --note ""` records it as an `external` entry; a nonce that created a contract is refused (it was a create of the deployer's, not an external transition), unless it is the record's own `keyExchange` contract. Update entries are matched by contract as well as nonce (each contract's identity-contract nonce starts at 1). A record is one deployer's: another identity is refused unless it registers a new set (`--force-new` without `--only`), which supersedes every recorded contract and archives the ledger in `v2.nonceLedgerSuperseded` (with `deployer`), as a chain change does. @@ -862,6 +871,8 @@ An update may add only optional properties, `enum` values appended at the end, a **UPDATE-2** (the passkey vault) is one more `DataContractUpdate`, of forge-meta alone: `vaultEntry` (§2, forge-meta), a new type with its own unique index and a `refersTo` to the owner's own authentication key, nothing on an existing type. It is the flag `passkey_vault` (`UPDATE2_FLAGS`, off in the registered v1 set; `stale_registered` turns it off with UPDATE-1's). On a network that is not registered yet (mainnet) it is part of the registration set and changes forge-meta's sha256, which the owner signs again. Testnet (`6arQ…`) and devnet sakura (`4CyD…`) registered forge-meta without it (source `04627b52…`), so there it ships as `deploy-v2.mjs --update meta` (applied on testnet on 2026-10-26, forge-meta version 2; sakura is retired and was not updated) and `contract-validate --expect-update` accepts the new forge-meta as an update of the registered one (`ALLOWED (DataContractUpdate v1 -> v2)`; run by hand against `git show ec3c86f12:forge-contracts/contracts/mainnet/forge-meta.json`, the file sakura registered, since no `registered/devnet-sakura/` copy is frozen for CI). Its vectors (`vaultEntry` cases of the `U2` item: shapes, bounds, the immutable `credentialId` and `recipientKey`, the re-seal, the index) are generated for the four-contract set (`vectors.py --mainnet`), and the committed three-contract vectors only assert that the type is absent there. +**UPDATE-3** (boards, [docs/design/boards.md](../design/boards.md) §3) is the next `DataContractUpdate` of forge-meta alone: `board` and `card` (§2, forge-meta), new types with their own indexes, the member gate `label` has, and `card.item`'s reference to forge-collab's issues and PRs; nothing on an existing type. It is the flag `boards` (`UPDATE3_FLAGS`, off in the registered v1 set with UPDATE-1's and UPDATE-2's), and testnet's `NETWORK_REGISTRATIONS` entry lists it under `since` beside `passkey_vault`, so `registered/testnet/` still matches what testnet registered. On mainnet it is part of the registration set. On testnet it ships as `deploy-v2.mjs --update meta` (forge-meta version 3; the update substitutes every recorded id, forge-collab's included), applied on 2026-10-27 at the deployer's contract nonce 3 (10,913 B, 0.461175 tDASH), after the same update on the scratch set. `contract-validate --expect-update` accepts the new forge-meta as an update of `registered/testnet/forge-meta.v1.json` (CI, `validate-registered.sh`) and of testnet's version 2 (`git show 84d6e2d4:forge-contracts/contracts/mainnet/forge-meta.json`, by hand: `ALLOWED`). The update transition is 10,913 B (the contract, 10,842 B, plus the update's framing), and it costs about 0.46 DASH: a contract update pays the whole contract's registration fee again (rs-drive-abci `execution_event`, 10 types and 16 indexes), measured 0.461175 DASH on testnet's scratch set (2026-10-27). Its vectors (the `U3` item: shapes and bounds, `noPlain`, `hasName`, `dependentRequired`, the roles, the immutable keys, a move, an archive, a remove, the indexes; the `rClaim` update guards in `--guards`) are generated for the four-contract set, and the committed three-contract vectors assert the types are absent. The member gate, its re-check on a replace and `card.item` are references, judged offline by the offline chain (`offline-chain.test.mjs`) and live by `forge-web/lib/repo/boards.live.test.ts`, which passed on testnet's scratch set and then on the live set after each forge-meta was updated to version 3: a member's boards and cards land; a non-member's card and board are refused by the gate (40120), a triage member's board by its role (40127), a removed member's replace of its own card by the gate re-checked on the replace (40120), and a card naming a document that is no issue or PR by `card.item`'s reference (40120) ([evidence](../../forge-contracts/evidence/testnet/README.md#forge-meta-update-to-version-3-boards-2026-10-27)). + **The mixed-visibility items (mainnet only).** dash-forge-qa `design/mixed-visibility/DESIGN.md` rev 4.1 §8.3 adds the layout and eleven items to `MAINNET_FLAGS`, in its order. Each is off in every devnet build and on with `build.py --mainnet`; `build.NEEDS` refuses a combination that cannot register (a `where` naming a property another item adds, or B1 without the room forge-meta leaves). Row numbers are DESIGN §8.2's. A refusal is 10422 (the first broken rule in name order), 40127 (a `where` mismatch) or 40120 (no document found), as M-C checks live. | # | Flag | Item | Contract | What consensus enforces | Until mainnet | diff --git a/docs/deploying-to-a-network.md b/docs/deploying-to-a-network.md index 962a199a6..061b027cc 100644 --- a/docs/deploying-to-a-network.md +++ b/docs/deploying-to-a-network.md @@ -26,7 +26,7 @@ Four contracts, in one contract group (`dash-forge`) that has an owner and **no | 1 | `forge-core` | repositories, members (`writer`, `maintainer`, `consent`), packs, refs, releases, config, `pushGrant`. Its create transition also creates the contract group. | | 2 | `forge-collab` | issues, pull requests, reviews, comments, transitions | | 3 | `forge-community` | `authorEvent`, `checkRun`, `event`, `milestone`, `policy`, `runner`, `star`, `watch`, `webhook` | -| 4 | `forge-meta` | `ban`, `follow`, `label`, `packMirror`, `profile`, `repoKey`, `topic`, `vaultEntry` ([forge-v2.md §2](contracts/forge-v2.md#forge-meta-mainnet-set-only)) | +| 4 | `forge-meta` | `ban`, `board`, `card`, `follow`, `label`, `packMirror`, `profile`, `repoKey`, `topic`, `vaultEntry` ([forge-v2.md §2](contracts/forge-v2.md#forge-meta-mainnet-set-only)) | The order is fixed. Each contract takes the deployer's next identity nonce, the contract and group ids derive from those nonces, and each later contract's schema names the ids of the ones registered before it. [forge-v2.md §8](contracts/forge-v2.md#8-deploying) has the details. diff --git a/docs/design/boards.md b/docs/design/boards.md new file mode 100644 index 000000000..1b965de52 --- /dev/null +++ b/docs/design/boards.md @@ -0,0 +1,275 @@ +# Boards: planning issues and pull requests + +Status: design, 2026-10-27 (UPDATE-3). Owner request: "build out a full, properly designed implementation of issue tracking boards, Jira / Trello ish. Make your own decisions; solve the same user stories as a GitHub project board, Trello and Jira." + +Constraints that shape every decision (`docs/research/platform-constraints.md`): one document operation per state transition; 5 KiB per field and 20 KiB per signed transition; 100 documents per query page; indexed strings ≤ 63 characters; no subscriptions (liveness is polling); **we host nothing** (no server runs automations, sends notifications or keeps a board's state); every write costs the writer credits. + +--- + +## 1. User stories + +The stories GitHub Projects, Trello and Jira all serve, and how Forge answers each. "Board" below is Forge's name for a GitHub *project*, a Trello *board* and a Jira *board*. + +| # | Story | Forge | +|---|---|---| +| U1 | Lay work out in stages (columns) and see at a glance what is where | Board view: one column per status, cards for issues and PRs (§4.1) | +| U2 | Move work between stages and prioritise within a stage by dragging | Drag and drop, and keyboard moves; one cheap write per move (§3.2, §5.2) | +| U3 | New work shows up on the board without anyone adding it | **Sources**: a board includes every issue / PR of the repos and filters it names (§2.3) | +| U4 | Finished work moves to Done by itself; old done work goes away | Closed and merged items show in the Done column; auto-archive after N days (§2.4) | +| U5 | Track more than status: priority, estimate, sprint, dates, free text | Custom fields: single select, number, date, iteration, text (§2.2) | +| U6 | Different people need different cuts of the same work | Saved views: board, table and roadmap layouts, each with a filter, a grouping, swimlanes, a sort (§4) | +| U7 | Filter to "mine", a label, a sprint, a priority | One query language shared with the Issues tab, plus board qualifiers (§4.4) | +| U8 | Plan in sprints; see the current one; carry over unfinished work | Iteration field with a cadence; `iteration:@current`; "move open items to the next iteration" (§2.2, §5.4) | +| U9 | Limit work in progress | Per-column WIP limits, shown and warned on, never blocking (§2.1) | +| U10 | Capture a card quickly | Quick add at the foot of a column: a title makes a real issue, `#12` or a URL adds an existing one (§5.3) | +| U11 | Work on a card without leaving the board | Side panel: body, labels, assignees, fields, state, comments link (§5.5) | +| U12 | From an issue, see which boards it is on and change its status there | Issue and PR sidebar "Boards" section (§5.6) | +| U13 | One board across several repositories | A board lives in a **home repository** and may source and hold items from any repository (§2.5) | +| U14 | Everyone can look; only the team can change it | Public boards in public repos; sealed boards in private repos; writes gated on the home repo's membership at consensus (§3) | +| U15 | See progress: counts, points, sprint burn | Column totals (count and a number field's sum) and an iteration progress bar (§4.5) | +| U16 | Script it | `dg board` (list, view, create, move, set, add, archive, remove) with `--json` (§6) | + +**Deliberately different.** + +- *No draft cards.* Trello cards and GitHub draft issues are a second kind of item that later has to be converted. On Forge an issue costs about as much as a card (0.0007–0.0012 vs 0.0004–0.0009 DASH) and already has comments, labels, assignees, a number, a URL and history, so quick add makes a real issue. One item model; nothing to convert. +- *No automation engine.* GitHub's workflows and Jira's automation run on a server when something happens. Forge hosts nothing, so automation is **derived**: rules in the board's definition that every reader applies when it renders (sources, the Done column, auto-archive). They are free (no writes), instant, consistent between the web and the CLI (shared vectors), and can never "fail to run". +- *No configurable workflow transitions* (Jira's "In review may only go to Done"). Statuses are columns; any member may move any card. Transition rules suit a ticketing desk, not a forge, and would be client-only anyway. +- *Board history is not kept.* A card's placement is one mutable document per member (§3.2): a move costs about 0.00005 DASH instead of 0.0004 or more, at the price of no per-move audit trail. Issue state history stays in the issue timeline, which is what matters. + +--- + +## 2. The model + +### 2.1 Board + +A board is a definition: name, description, columns, fields, sources, views and rules. Its **key** is a random u32 chosen at creation (URLs: `/repo/board?owner=&name=&b=`); every revision of the board carries the same key. + +**Columns** (1–20): `{id, name, color?, wip?}`. `id` is 1–255, stable across renames; order is the array order. One column may be the **Done** column (`done`), and one the **default** column (`def`: where an item with no placement shows; 0 = a "No status" column shown only while it holds something). + +### 2.2 Fields + +Up to 12 custom fields `{id, name, type, …}`, `id` 1–255 stable: + +| type | value | notes | +|---|---|---| +| `sel` single select | option id (1–255) | options `{id, name, color?}`, ≤ 30 | +| `num` number | finite number | e.g. Estimate / story points; summed in column totals | +| `date` | `YYYY-MM-DD` | e.g. Start, Target; the roadmap layout plots them | +| `iter` iteration | iteration index ≥ 0 | `start` (`YYYY-MM-DD`) + `days` (1–90); iteration *k* runs from `start + k·days` for `days` days, named " k+1" | +| `text` | string ≤ 200 chars | | + +Built-in fields come from the item itself and are never stored on the board: Title, Number, Repository, State, Author, Assignees, Labels, Milestone, Created, plus Status (the column). + +### 2.3 Sources (auto-include) + +Up to 5 sources `{r, k, q}`: a repository id (`r`, default the home repo), a kind (`i` issues, `p` pull requests, `a` both) and a filter in the board query language (§4.4, default empty = all). Every item a source matches is on the board, open or closed, unless a member removed it (§2.4). A board with no sources holds only the items members added. The new-board template sources the home repository's issues and pull requests. + +### 2.4 Placement: where an item shows + +For each item the reader takes the **newest card** (§3.2) over every member's, by (`$updatedAt`, `$id`). An item is **on the board** when a source matches it or it has a card, and that card is not *removed*. + +Its column: + +1. A **closed or merged** item shows in the Done column, unless its card puts it in a column at or after the Done column in the column order (a "Verified" or "Released" stage after Done keeps its items). +2. Otherwise the card's column, if the board still has that column. +3. Otherwise the default column (or "No status"). + +An open item may sit in Done (a team that marks work done before closing). A board without a Done column applies rule 2 and 3 only. + +**Which closed items a reader reads.** A source's open items are read whole; its closed and merged ones from the repository's state changes newest first, until the auto-archive window ends (older ones are archived unless a card keeps them, and the items cards name are read by id anyway), or, with `arch` 0, until the 200 most recently closed of that source **repository** (all its sources together) are found; "Show older" (and a view asking for `is:archived`) reads on. + +**Auto-archive** (`arch`, days, 0 = off): let `closedAt` be the `$createdAt` of the item's latest transition into closed or merged (the transition that made its `sum mod 16` closed or merged). A closed or merged item whose newest card is older than `closedAt` (or which has none) is archived once `now ≥ closedAt + arch` days. `now` is an explicit input of the fold (the vectors pin it). Reopening never clears a card's archived state (as on GitHub). **Archived** items (auto or by a card's state) are hidden unless the view asks for them (`is:archived`). A **removed** item is off the board even if a source matches it; adding it again writes an active card. + +**Order within a column** is by rank (§2.6), ascending; a view may sort by a field instead (§4). + +### 2.5 Home repository and cross-repository boards + +A board's documents carry its home repo's id, and consensus admits them only from that repo's maintainers and members (§3). Its items may be any repository's issues and pull requests: a source may name another repository, and a card may name any item. An "organisation board" is a board in a planning repository (Forge has no organisations; an owner identity's repos are its organisation). + +What a reader may see of a cross-repo item is what that repository shows it: a private repository's issue on a public board shows as "a private item" unless the reader holds that repo's key (on the web, a member of that repository whose tab already holds its session, having opened it; in `dg`, a signer who is one of its members). Neither client reads anything to find out: the web looks only in the sessions this tab holds, and `dg` loads the signer's key for it as it would to read it. A private source repository whose key the reader does not hold is not read at all. + +### 2.6 Rank + +A card's `rank` is a string over the 62 digits `0-9A-Za-z` (ASCII order, so byte order is numeric order), read as a base-62 fraction; an explicit rank never ends in `0` and is at most 63 characters. Items sort by `(rank, item $id)`. + +- **Implicit rank.** An item with no card, or whose newest card has no rank, ranks `V` + the **item's** `$createdAt` in 8 zero-padded base-62 digits + the first 3 bytes of the item's `$id` (big-endian, mod 62⁴) in 4 digits. Sourced items therefore form a pool (`V…`) in creation order, oldest first, almost never two equal (two items of one block whose id prefixes collide mod 62⁴ tie, and sort by `$id`), and a card can be dropped between two of them without ranking either. An implicit rank may end in `0`; only the midpoint arithmetic treats trailing `0`s as absent. +- **Moves.** Dropping between two neighbours writes `rankBetween(a, b)`, a string strictly between them (digit-wise midpoint; vectors `board_rank__*`). **Top** of a column: `rankBetween("", min(first, "V"))`. **Bottom**: `rankBetween(max(last, "W"), "")`. So explicit top and bottom groups bracket the sourced pool, and later sourced items (which join the pool) never pass a card dropped at the bottom. A card dropped between two sourced items gets a `V…` rank, which later sourced items may pass; that is intended (they are newer). +- **Overflow.** A rank that would exceed 63 characters (about 350 drops into one gap) is refused before signing with "Re-rank this column", which rewrites the column's ranks evenly: one write per item, a create (≈ 0.0004–0.0009 DASH) for each item the signer has no card for, priced before signing. `rerank(n)` spreads them between `0` and `V` (k/(n+1) of the way, in the fewest digits that leave 62 ranks between neighbours), so items sourced later still join below them, in the pool. The pairs with no rank between are equal ranks (two members dropping into one gap at once write the same rank) and `b` = `a` + `0…0` (an explicit rank against an implicit one ending in `0`); both are `re-rank` too. + +### 2.7 Encoding and the rules both clients apply + +Pinned by `forge-web/lib/rules/boards.ts` and forge-core `rules::boards` (vectors `board_spec__*`, `board_query__*`, `board_view__*`). + +- **Spec JSON** (`v: 1`): `{v, desc?, columns, def?, done?, sources?, fields?, views?, arch?}`; a column `{id, name, color?, wip?}`; a field `{id, name, type, options?, start?, days?}` (`options` exactly on `sel`, `start` / `days` exactly on `iter`), an option `{id, name, color?}`; a source `{r?, k, q?}`; a view `{id, name, layout, q?, group?, lane?, sort?, cols?, date?}`. Written canonically: that key order, compact, defaults (0, `""`, `[]`) omitted (an empty `desc` is none), so equal specs are equal bytes. JSON that forge-core's reader (serde_json) refuses is refused by both clients: an unpaired surrogate escape, a number out of range (`1e400`), nesting past 127 levels; forge-core reads numbers exactly (`float_roundtrip`), as `JSON.parse` does. Unknown keys are tolerated on read and dropped on write (a change older editors must keep bumps `v`); a known key of the wrong type refuses the spec, naming the first problem in key order. Colors are `#rrggbb` (the label schema's); `wip` 1–9999; `desc` ≤ 1024 characters; queries ≤ 512 characters; `arch` ≤ 3650. +- **Names** (columns, fields, options, views): 1–63 characters, no control character or `"`, no leading or trailing white space, unique in any letter case. A field name may not contain `:`, start with `-`, or be a query key or built-in field (`is`, `state`, `label(s)`, `assignee(s)`, `author`, `milestone`, `no`, `status`, `repo(sitory)`, `title`, `number`, `created`), so `:` is never ambiguous. +- **View keys**: built-ins by name (`status`, `assignee`, `label`, `milestone`, `repo`, `title`, `number`, `created`, `author`, `state`, `assignees`, `labels`), a custom field as `f`; `sort` takes `-` for descending. The board layout groups by `status` or a `sel` / `iter` field; lanes never by `status` or the grouping; `date` is one `iter` field or two different `date` fields. Every reference must resolve. +- **Field values** (`card.f`): `sel` an option id, `num` finite with |x| ≤ 1e15 and 0 or |x| ≥ 1e-6 (so both clients print it alike, without an exponent: JavaScript's shortest digits, an exact tie to even), `date` a calendar `YYYY-MM-DD`, `iter` 0–65535, `text` 1–200 characters. Anything else is dropped on read. Written ids ascending. +- **Sources** read only the item: a source query's `status:`, field, `is:archived` and `@me` qualifiers are reported, not applied (a source includes the same items for every reader, before any card); its `repo:` takes a repository id only. +- **Query** additions to §4.4: `is:unmerged` (open or closed, as on the Pull requests tab), `state:` as `is:` for states, a leading `-` on any qualifier (a missing value never matches, so `-priority:P0` matches items with no priority), number and date ranges `a..b` / `*..b` / `a..*`, `@today`, `iteration:N` (iteration N) or by name, `iteration:<@current`, text fields matched as contains. Names and values with spaces are quoted (`"story points":>3`). Before an iteration field's first iteration `@next` is iteration 1 and `@current` / `@previous` match nothing. A token naming nothing on the board is reported, as is a known key with nothing after its colon (`label:`); an unknown key with nothing after it (`note:`) and a URL stay text. Free text matches titles and numbers as the Issues tab's does (no bodies on a board). **`repo:`** matches by repository id, never by how a client labels a repository: a value that is an id is taken as is; `owner/name` (the owner an identity id or a DPNS name) or a bare `name` (a repository of the home repository's owner) is resolved to its id by the client before the query is parsed (`repoNamesOf` / `repo_names_of` list the names, both clients resolve them alike), and a name that resolves to nothing is reported (vectors `board_query__parse_repo`, `board_query__repo_names`). +- **Groups** (§4.1, §4.2): "No " first, only while it holds an item; then every column, every option, the iterations items name plus the current one, or the distinct assignees / labels / milestones / repositories by code point (repositories by id; an item with two assignees or labels is in both). **Sorts**: items without a value last in both directions; ties by (rank, item id); `repo` by repository id (vector `board_view__sort_repo`). A repository's label (`owner/name`) is display only. + +--- + +## 3. Contract: two new forge-meta types (UPDATE-3) + +New document types only, added to forge-meta by `deploy-v2.mjs --update meta` on a registered network (forge-meta v3 on testnet since 2026-10-27, rehearsed on its scratch set first) and part of the registration set elsewhere. Flag `boards` (UPDATE3), four-contract set only, as `passkey_vault`. + +Both types are **mutable and never deleted, one document per (member, board[, item])** (`canBeDeleted: false`: deleting the newest document would silently bring back an older member's, which no poll of `$updatedAt` sees, and a removed member could still delete theirs; `state` 2 is the delete). Every index key and both timestamps are `required` (an unrequired `$updatedAt` is never recorded, and a unique index does not hold a document missing a key part). A member's later write replaces their own document (a replace costs a fraction of a create: on testnet a card's move 4.2M–4.9M credits against its create's 43M–89M), and readers take the newest across members. Both are member-gated like `label`: `ownerRefersTo` a forge-core `maintainer` or a `writer` whose `role` equals the claimed `r`, re-validated on every replace, so a removed member cannot touch their old documents and a role change takes effect on the next write. + +### 3.1 `board` + +| property | type | notes | +|---|---|---| +| `repoId` | id, immutable | the home repository | +| `key` | u32 1–4294967295, immutable | the board | +| `name` | string 1–63 chars, ≤ 252 B, visible character | plaintext boards only | +| `spec` | string ≤ 4096 B | the definition (§2), JSON, `v: 1`; plaintext boards only | +| `state` | integer 0–2 | 0 open, 1 closed (read-only, listed under Closed), 2 deleted | +| `enc`, `epoch` | bytes 29–5120, u32 | a private repo's board: `name` and `spec` sealed together | +| `r` | integer 1–1 (rule `rClaim`: `r = 1`) | maintainers and role-1 writers define boards (a writer may close or delete a maintainer's board, as with labels) | + +Unique index `byKey (repoId, key, $ownerId)`; its `repoId` prefix lists a repo's boards. Rules: `noPlain` (with `enc`, no `name` / `spec`), `hasName` (without `enc`, `name` and `spec`), `dependentRequired enc → epoch`. + +### 3.2 `card` + +A member's placement and field values for one item on one board. + +| property | type | notes | +|---|---|---| +| `repoId` | id, immutable | the board's home repository (the gate) | +| `board` | u32, immutable | the board's key | +| `item` | identifier, immutable, `refersTo` forge-collab `issue` or `patch` (any repository) | | +| `col` | integer 0–255 | column id; 0 = none | +| `rank` | string 1–63 chars, `^[0-9A-Za-z]*[1-9A-Za-z]$` | | +| `f` | string ≤ 2048 B | field values, JSON `{"": value}` | +| `state` | integer 0–2 | 0 active, 1 archived, 2 removed | +| `enc`, `epoch` | bytes 29–2560, u32 | a private repo's card: `col`, `rank`, `f` sealed | +| `r` | integer 1–2 | maintainers, writers and triage place cards | + +Indexes: unique `onItem (item, repoId, board, $ownerId)` (one card per member per item per board; its `item` prefix answers "which boards is this issue on") and `recent (repoId, board, $updatedAt)` (load a board, and poll for what changed since). Rules: `noPlain` (with `enc`, no `col` / `rank` / `f`). + +`state` stays plaintext in a private repo: it tells only that an item was archived or removed. + +**Why one document per member and not one per item.** Platform documents are replaced only by their owner. One document per item would need every member to create a new immutable document per move (0.0004 DASH or more, forever growing). Per-member mutable documents make every move after a member's first a replace. + +**Concurrent edits.** A card carries all of a member's view of the item (column, rank, fields), and the newest wins whole. A client reads the item's newest card immediately before signing and applies only its own change to it, so two members editing different fields of one card both land unless the second read happens before the first write is visible (the read-to-sign latency, a few seconds); then the last writer wins whole. + +A member's **own** back-to-back edits never undo each other within one client: it keeps the card each write of an item landed (with the `$revision` the write made) and, while a fresh read lags behind it (lacks the document or holds an older revision), applies the next change over that card instead of the read; once the read caught up, the read is the base again (another member's later card included). The web keeps them 60 s per page, for single and bulk writes alike (`overIfAhead`); `dg` keeps them for the process. Two `dg` processes run one after the other share nothing: if the second reads a node that has not seen the first's write yet, it builds on the older card, so a script that makes two writes to one item should check the first landed (`dg board view`) or wait a few seconds between them. A create that meets the signer's card made meanwhile (another tab or device) re-reads and applies its change over the newest card then. + +**Gates fixed by this registration** (an update can never add an `ownerRefersTo` operand): only the **home** repository's members place cards (a member of the item's repository who is not one of the home repo's cannot); a card always names an issue or PR (`item` required, with `refersTo`), so there are no item-less notes; writers (role 1) define boards, triage does not. + +### 3.3 Private repositories + +A private repository's boards and cards are sealed with the repository key under the current epoch, with the private-repos per-document framing (`docs/security/private-repos.md` §4.4): new `docType`s `board` and `card`, bound to `u32(key)` and `u32(board) ‖ item (32 B)` respectively, so a sealed payload cannot be moved to another board or item. Readers of a private repo see nothing; the keys, `state` and the item ids are all that is plaintext. + +The payload encoding (TLV tags 32–36, padding, the read order) is `private-repos.md` §4.6, pinned by the `sealed_board__*` vectors. A version other than `0x01` reads as unreadable, not malformed, so a later client's members-only boards stay listed. + +**What a private board still shows.** `item` is plaintext, immutable and indexed, so a card in a private planning repository that names a *public* repository's issue publishes "private repository R tracks owner/name#12" (and which member wrote it). Clients confirm before writing such a cross-repository card from a private home repo (the web refuses the write until the caller passes the confirmation: `crossRepoCardNeedsConfirm`, `BoardWriteError` `cross-repo`). A public repository's members-only boards (the members key, `enc` v0x03) are possible with this schema and left to a later client. + +--- + +## 4. Views + +A view is `{id, name, layout, q, group, lane, sort, cols?, date?}`, at most 8 per board, saved in the board definition. Unsaved changes live in the URL (`?b=&view=&q=&group=&lane=&sort=`, and `&layout=`, `&cols=`, `&date=` for a layout switched or columns picked), so any cut can be shared as a link; a member saves it into the definition. An open item panel is `&item=`. + +### 4.1 Board layout + +Columns are the values of the grouping field: Status by default, or any single-select or iteration field (dragging then sets that field). **Swimlanes** (`lane`) split the board horizontally by assignee, label, milestone, repository, a single-select or an iteration field. Cards show the repo (when the board spans several), number, title, state icon, labels, assignees, and the view's chosen fields (`cols`). + +### 4.2 Table layout + +One row per item; columns are the built-in and custom fields the view lists (`cols`); click a header to sort; grouping makes sections with counts and sums; cells of custom fields and Status are edited in place by members. + +### 4.3 Roadmap layout + +A timeline: each item is a bar from its start date to its target date (`date: [startFieldId, endFieldId]`) or across its iteration (`date: [iterFieldId]`); items with no dates are listed beside it. Zoom: weeks, months, quarters. Today and the iterations are marked. + +### 4.4 Query language + +The Issues tab's qualifiers (`is:open|closed|merged`, `is:issue|pr`, `label:`, `-label:`, `no:label`, `assignee:@me`, `no:assignee`, `author:`, `milestone:`, `no:milestone`, free text and `#12`) plus: + +- `status:"In progress"` / `-status:Done` / `no:status` +- `:` for a custom field by name: `priority:P0`, `estimate:>3`, `target:<2026-11-01`, `iteration:@current`, `iteration:@next`, `iteration:@previous`, `no:priority` +- `repo:owner/name` (or a repository id; §2.7) +- `is:archived` (otherwise archived items are hidden) + +Names match case-insensitively; values with spaces are quoted. An unknown field or value is reported under the box, never searched as text. + +### 4.5 Totals and progress + +Each column (and each swimlane and table group) shows its item count, its WIP limit when set (red when over), and the sum of the view's first number field. With an iteration field, the board header shows the current iteration's dates and done / total (count and points). + +--- + +## 5. Interaction + +### 5.1 Who can do what + +| | stranger / reader | triage | writer | maintainer | +|---|---|---|---|---| +| view a public board | yes | yes | yes | yes | +| move, rank, set fields, add, archive, remove items | | yes | yes | yes | +| create, edit, close, delete a board; save views | | | yes | yes | + +The UI offers only what the viewer's role allows and the contract's gate refuses the rest. + +### 5.2 Moving + +Drag a card (pointer or touch; on a touch screen by its grip, so a swipe elsewhere still scrolls the board); keyboard: focus a card, `Space` to pick it up, arrows to move, `Space` to drop, `Esc` to cancel (with live-region announcements). The board moves the card at once (optimistic), signs one write (`card` create, or replace of the signer's own), and puts it back with the reason if the write is refused. Dropping into a column over its WIP limit warns and still moves. + +### 5.3 Adding + +Quick add at the foot of each column: a title makes an issue in the home repo (or a source repo chosen from a menu) and places it there; `#12`, `owner/name#12` or an issue / PR URL adds that item. "Add items" opens a search over the source repos' issues and PRs not on the board. + +### 5.4 Iterations + +"Move open items to the next iteration" sets the iteration field of every open item of the current iteration that is not in the Done column (one write per item, priced first). + +### 5.5 Item panel + +Clicking a card opens a side panel: title, state, body (markdown), labels, assignees, milestone, the board's fields and status (editable by members), archive / remove, and a link to the issue or PR. Labels and assignees edits are the issue's own events. + +### 5.6 On an issue or pull request + +The sidebar's "Boards" section lists the boards it is on whose home is the item's repository or another repository of the same owner, with its status and fields (editable), and "Add to board" for that repository's other boards. It reads the owner's repositories first (up to 300), then `card.onItem` with `item ==` the item and `repoId in` those repositories (100 a query, up to 3 pages each), so a stranger's cards naming the issue are never read and cost the page nothing. Another repository of the owner that is private is left out: its boards are sealed with a key the item's page does not hold. The section reads once it is in view and the page's own load is past (the reader scrolls, points at or focuses it, or the browser has been idle 8 s after it mounted), so a cold issue or PR page spends no request on it even where the sidebar starts in view (`page-budget.spec.ts` pb-6). + +### 5.7 Liveness + +An open board polls `card.recent` for cards with `$updatedAt >=` its last read (deduplicated by `$id`: several cards can share a block time) every 20 s while the tab is visible, and re-reads the definition on focus. A refresh control forces both. + +--- + +## 6. CLI + +`dg board list []`, `dg board view [--view ] [--json]`, `dg board create --name [--columns "Todo,In progress,Done"]`, `dg board move <#n> [--top|--bottom|--before <#m>|--after <#m>]`, `dg board set <#n> =…`, `dg board add|archive|remove <#n|owner/name#n>…` (`add --title ` is quick add, §5.3; `archive --restore` unarchives), `dg board next-iteration [--field ]` (§5.4), `dg board close [--reopen]` and `dg board delete `. `create --template kanban|sprint|triage|empty` writes the web's create-dialog templates (`forge-web/components/repo/boards/board-templates.ts`). An item is `#n` in the home repository, `owner/name#n` elsewhere, and `pr#n` / `issue#n` where an issue and a pull request share the number. The CLI reads a source repository's issues whole and its pull requests page after page (newest first, up to 3,000, as far as the web reads open ones), then keeps the closed ones as the web's walk does (the auto-archive window, or the 200 most recently closed); `view --archived` (or a view asking for `is:archived`) keeps the next 200 closed ones too, as the web's "Show older" reads them. The data layer is forge-core `collab::boards` (sealing: `private::board`, vectors `sealed_board__*`). The fold, rank and query rules are shared with the web (`forge-core::rules::boards`, `forge-web/lib/rules/boards.ts`, vectors `forge-contracts/vectors/board_*__*.json`). + +--- + +## 7. Costs + +Measured on testnet (2026-10-27, `forge-web/lib/repo/boards.live.test.ts`: three runs on the scratch set's forge-meta v3, then one on the live set's, whose fees fell within these ranges; the model is `forge-web/lib/sdk/cost.ts`, `board` and `card` in `BASE_CREDITS`, `FIRST_WRITE_CREDITS` and `REPLACE_BASE_BY_TYPE`): + +| Write | Credits | ≈ DASH | +|---|---|---| +| A board (the Kanban template, 738 bytes of name and definition): a repository's first | 62.8M–63.8M | 0.00064 | +| A repository's later board | 53.7M–54.7M | 0.00055 | +| A board's rename, close, reopen or delete (a replace) | 3.4M–4.6M | 0.00004–0.00005 | +| A card for an item another member already has a card for | 42.8M–43.2M | 0.00043 | +| An item's first card on the board | 70.5M–70.9M | 0.00071 | +| A board's first card (also the item's first) | 88.3M–89.1M | 0.00089 | +| A card's move (column and rank), field change or archive (a replace) | 4.2M–5.2M | 0.00005 | +| A write consensus refuses (a non-member's card or board, a removed member's replace, a card naming no issue or PR) | 1.6M–2.1M (once 10.3M) | 0.00002–0.0001 | + +A board's text is priced per byte (27,500 credits), so a longer definition costs more. Sources, Done, auto-archive and views cost nothing. `priceBoardWrites(creates, replaces)` prices a multi-write action (a re-rank, "move to the next iteration", a bulk archive) before it is signed. + +## 8. Limits + +| | | +|---|---| +| columns | 20 | +| fields | 12, ≤ 30 options each | +| sources | 5 | +| views | 8 | +| definition | 4096 B of JSON | +| field values per card | 2048 B of JSON | +| items | no cap; a board reads 100 cards per page, so very large boards load progressively | diff --git a/docs/economics.md b/docs/economics.md index 2e9fcbcd4..c9ad38ec5 100644 --- a/docs/economics.md +++ b/docs/economics.md @@ -94,6 +94,7 @@ All in DASH, **measured on devnets** (to be re-measured on testnet); fiat figure | Push 100 KiB source delta (~30 KiB packed) | about 0.015–0.02 DASH (~$0.45–0.60): 0.33–0.36 DASH/MiB for the packed bytes plus ~0.004–0.011 for the manifests, ref update and history index. Permanent | ~0.004–0.0055 DASH (~$0.12–0.17): manifests and the ref update only | | 1,000 issues + 5,000 comments over a year | **~3.1–4.5 DASH** (~$95–135) for short bodies (issues 0.0006–0.001 each, comments 0.0005–0.0007 each; more with long bodies). Issues are permanent, comments refundable on delete | same (always on Platform) | | Add a passkey for other devices, then sign in with it elsewhere | **~0.0005 DASH** for an identity's first (43–52M credits measured on testnet), ~0.0003 for each later one (33M); re-sealing after a key change ~0.00003; removing one refunds ~0.0003–0.0004; signing in is free. Paid from the browser key's budget ([passkey vault](security/passkey-vault.md)) | same | +| Plan on a board: create one that sources a repository's issues, then move 20 of them three times each | **~0.017 DASH**: the board ~0.0006; each issue's first move writes your card for it, ~0.0007 (the board's first ~0.0009); each later move replaces it, ~0.00005 (measured on testnet, [guides/costs.md](guides/costs.md#boards)). Not refundable: a board or card is never deleted, only marked so | same | | Remove one member from a 50-member repository with members-only content | ~0.035 DASH: the key is changed for the 49 who remain ([guides/costs.md](guides/costs.md#members-only-and-private-content)) | same | | Force-push away 10 MiB of history, then repack | nothing recovered; the repack adds a deposit for the consolidated pack | delete the old objects in your bucket | | Deployer: register the production set (once per network) | **~1.86 DASH for the four contracts** (0.5968 + 0.3963 + 0.5063 + 0.3636), measured on a Platform v5 devnet, and 1.873 DASH on testnet (2026-10-26); ~1.73 DASH for the three-contract devnet set ([Deploying Forge to a network](deploying-to-a-network.md#4-what-it-costs), [forge-v2.md §7](contracts/forge-v2.md#7-measured-size-and-cost)) | same | diff --git a/docs/guides/README.md b/docs/guides/README.md index 85f59eaf5..33cc161de 100644 --- a/docs/guides/README.md +++ b/docs/guides/README.md @@ -12,6 +12,7 @@ Task-oriented guides for using Dash Forge. For how it is built, see the [documen | [Storage on your home NAS](home-nas-storage.md) | run RustFS or Garage (or kubo) on a Synology, TrueNAS or Linux box, publish it safely with a Cloudflare Tunnel, and keep a second copy | | [Run your own IPFS node](run-your-own-ipfs-node.md) | set up a node with one command (`dg ipfs up`), connect it to the web app, push to it, and keep a copy of someone else's repository with `dg ipfs pin` | | [Collaborating](collaborating.md) | add members, work with issues, pull requests, reviews, merges, releases and webhooks | +| [Boards](boards.md) | plan issues and pull requests on a board: columns, fields, iterations and views, from `dg board` | | [Bots and agents](bots.md) | add a bot, say what it may do, ask an agent to work on an issue or pull request, and give it push access to chosen branches (beta) | | [Who can read what](../security/audiences.md) | keep issues, comments and reviews of a public repository members-only, and know who can read them, what everyone still sees and what can still leak | | [Environments](environments.md) | keep configuration and secrets outside git, encrypted for your maintainers or members, and inject them with `dg env run` | diff --git a/docs/guides/boards.md b/docs/guides/boards.md new file mode 100644 index 000000000..b856acd99 --- /dev/null +++ b/docs/guides/boards.md @@ -0,0 +1,54 @@ +# Boards + +A board lays a repository's issues and pull requests out in columns (Todo, In progress, Done…), with fields such as priority, estimate and iteration, and saved views. It is Forge's GitHub project, Trello board or Jira board. How boards work, and why, is in the [boards design](../design/boards.md). + +- **Who can do what.** Anyone can look at a public repository's boards. Maintainers, writers and triage members move items, set their fields, and add, archive or remove them. Maintainers and writers create, edit, close and delete boards. +- **What shows on a board.** A board's *sources* bring in items by themselves (the new-board templates take every issue and pull request of the repository, or every issue labelled `bug`); members add others by hand, from any repository. Closed and merged items go to the Done column, and leave the board once they have been closed for longer than its auto-archive time (14 days in the templates). +- **What it costs.** Each change is one document. Your first card for an item (an item a source shows on the board has no card until someone moves it) costs about 0.0007 DASH, 0.0009 for the board's first card, and 0.0004 when another member already has a card for it; every later move, field change or archive of it about 0.00005 DASH. A new board costs about 0.0006 DASH, and an edit, close or delete about 0.00005 (measured on testnet). Every command shows its price and asks before it spends (`--yes` skips the question). +- **Private repositories.** A private repository's boards and cards are encrypted for its members. The items a card names are not: a card on a private board that names another repository's issue tells everyone that the private repository tracks it, so `dg` asks first. +- **Networks.** Boards need the boards update of the Forge contracts (testnet has it since 2026-10-27). Until a network has it, every `dg board` command stops with E702. + +## From the command line + +Name a board by its number (from `dg board list`) or its name. Name an item `#12` (or `12`) in the board's repository, `owner/name#12` in another, and `pr#12` when an issue and a pull request share the number. Inside a clone, the repository can be left out, as with every `dg` command. + +```sh +dg board list / # --deleted to include deleted boards +dg board create / --name Roadmap # Todo, In progress, Done +dg board create / --name Sprints --template sprint +dg board create / --name Release --columns "Backlog,Doing,Review,Done" +dg board view / Roadmap # every column, its items and totals +dg board view / Roadmap --view Table # as a saved view filters and sorts it +``` + +`--template` is one of the web's: `kanban` (the default: Todo, In progress and Done, every issue and pull request, Priority, Estimate and a two-week Iteration), `sprint` (Backlog to In review and Done, two-week sprints and estimates), `triage` (issues labelled `bug`, from Needs triage to Fixed, with a Priority) and `empty` (one column, nothing added for you). `--columns` replaces the template's columns; a column named Done takes closed and merged items. Running the same `create` again (the same name and columns) finds the board the first run made instead of making a second one. + +`dg board view` prints each column with its items, their fields, the item count, the sum of the first number field (an estimate) and the work-in-progress limit, marked when a column is over it. With an iteration field it ends with the current iteration's progress. `--archived` shows archived items too. With `--json` it prints the board, each column, each item with its column, rank and fields, and `fold`, the placement every Forge client computes ([schema](../schemas/dg/board-view.schema.json)). + +Moving and planning: + +```sh +dg board move / Roadmap #12 "In progress" # to the bottom +dg board move / Roadmap #12 "In progress" --top +dg board move / Roadmap #12 Done --before #9 # or --after #9 +dg board set / Roadmap #12 priority=P1 estimate=3 iteration=@next +dg board set / Roadmap #12 estimate= # clear a field +dg board next-iteration / Sprints # carry unfinished work over +``` + +`dg board set` takes fields by the names the board gives them: an option's name for a select field, a number, a date (`YYYY-MM-DD` or `@today`), an iteration (`@current`, `@next`, `@previous`, or its number), or text; `status=` moves the item. `dg board next-iteration` moves every open item of the current iteration that is not in the Done column into the next one, one write each, priced together first. + +Adding and removing: + +```sh +dg board add / Roadmap #12 #15 alice/lib#3 --column Todo +dg board add / Roadmap --title "Login page is slow" # opens a new issue there +dg board archive / Roadmap #4 #7 # --restore brings them back +dg board remove / Roadmap #9 # even if a source includes it +dg board close / Roadmap # read-only; --reopen +dg board delete / Roadmap +``` + +A command that changes several items writes them one by one; when one fails, the ones before it have landed, and it stops with E106 saying which. Run it again: items that already have the change cost nothing more. + +A card is yours: each member has their own card for an item on a board, and everyone sees the newest. `dg` reads the item's newest card just before it signs and changes only what you asked for, so two members editing different fields of one item both land. Two `dg` commands run back to back on one item (a script's `set` then `move`) can, rarely, have the second read a node that has not seen the first write yet, and undo it; check with `dg board view` between them, or wait a few seconds. diff --git a/docs/guides/collaborating.md b/docs/guides/collaborating.md index b7c418002..2c158a7b8 100644 --- a/docs/guides/collaborating.md +++ b/docs/guides/collaborating.md @@ -670,6 +670,19 @@ dg issue milestone / 12 v1.0 On the web, **Issues → Milestones** lists them open and closed, with due dates and progress, and lets members create, edit, close, reopen and delete them. Like a label, a milestone keeps its title once defined. A milestone definition can be deleted only by the member who wrote it, so one another member also defined can be closed but not deleted. Milestones in a private repository are encrypted, which this release does not do yet (web or `dg`). +### Boards + +Boards lay issues and pull requests out in columns, with fields, iterations and saved views (GitHub's projects). Triage members and up move and place items; maintainers and writers create boards: + +```sh +dg board create / --name Roadmap +dg board view / Roadmap +dg board move / Roadmap #12 "In progress" +dg board set / Roadmap #12 priority=P1 estimate=3 +``` + +The [Boards guide](boards.md) has every command. + ### Stars ```sh diff --git a/docs/guides/costs.md b/docs/guides/costs.md index 2cece2e99..62640d225 100644 --- a/docs/guides/costs.md +++ b/docs/guides/costs.md @@ -258,6 +258,17 @@ A passkey's entry is one small stored item, written with this browser's key (so At most 10 passkeys per identity. An entry is always the same size, whatever keys it holds. +### Boards + +A board's definition is one document per member who edits it, and a card one document per member, item and board, replaced in place by every later change ([boards design](../design/boards.md#7-costs)). Measured on testnet (2026-10-27, on the scratch set and the live set) with the live test (`lib/repo/boards.live.test.ts`), which prints what each write costs. + +| Action | About | Notes | +|---|---|---| +| Create a board | 0.00064 DASH, 0.00055 for a repository's later boards | with the Kanban template's 738 bytes of name and definition; a longer definition costs more | +| Edit, close, reopen or delete a board | 0.00004–0.00005 DASH | a replace of your revision | +| Put an item on a board, or move a sourced item for the first time | 0.00071 DASH for the item's first card, 0.00089 for the board's first, 0.00043 when another member already has a card for it | your first card for the item | +| Move a card, set its fields, archive or remove it | 0.00005 DASH | a replace of your card | + ## Platform or your own bucket Pack bytes are almost all of a repository's size, so where you keep them decides the cost: diff --git a/docs/limits.md b/docs/limits.md index b55ecffe7..2a613a9c5 100644 --- a/docs/limits.md +++ b/docs/limits.md @@ -18,6 +18,8 @@ What Forge cannot hold or do, in numbers, with where each number comes from. Som | A pack | **1 TiB**: the cap on the size a manifest records (**frozen**). Forge's tools add no smaller cap; on Platform a pack is split over as many chunks as it needs, each costing about 0.005 DASH | [forge-v2.md §9](contracts/forge-v2.md#9-frozen-at-mainnet); [Costs](guides/costs.md) | | A contract (registration) | 20,480 bytes, and at least 2,000 bytes of headroom under that for the create transition | `deploy-v2.mjs` | | A passkey vault entry (`vaultEntry`) | credential id 16 to 255 bytes, recipient key 32, encapsulated key 32, sealed bundle 32 to 256 (Forge writes 256). An update can loosen the sealed bundle's bounds but never make it fixed-length, and cannot take the credential id past 255 bytes or `version` past 255 (**frozen**). One entry per identity and credential. Fees measured on testnet: about 43 to 52 million credits (about 0.0005 DASH) for an identity's first entry, 33 million for a later one, 3 million to re-seal; a delete refunds about 27 to 37 million, and a sign-in reads only | [forge-v2.md §2](contracts/forge-v2.md#forge-meta-mainnet-set-only) | +| A board (`board`, forge-meta) | name 1 to 63 characters (252 bytes), definition 4,096 bytes of JSON, sealed 5,120 bytes; one definition per member and board. The board key stays a u32 and only maintainers and writers define boards (**frozen**); the size bounds can be loosened by an update. Fees measured on testnet: about 54 to 64 million credits for a new board with a template's definition, 3.4 to 4.6 million for an edit | [forge-v2.md §2](contracts/forge-v2.md#forge-meta-mainnet-set-only); [Boards](design/boards.md#8-limits) | +| A card (`card`, forge-meta) | column 0 to 255, rank 1 to 63 base-62 digits, field values 2,048 bytes of JSON, sealed 2,560 bytes; one card per member, item and board. A card always names an issue or a PR, and only the board's home repository's members write one (**frozen**). Fees measured on testnet: about 71 million credits for an item's first card, 89 million for a board's first, 43 million when another member has a card for the item, 4 to 5 million for a move | same | | Keys in a passkey vault entry | at most **6**: the main key (a group-bound limited key with a budget and an expiry), up to 4 per-contract wallet grants (each also with a budget and an expiry: an unlimited one stays on its device) and one encryption key (only if asked). At most **10 passkeys** per identity | [Passkey vault](security/passkey-vault.md#what-an-entry-holds) | | Pack download time | each copy gets `max(120 s, size ÷ 1 MiB/s)`; a manifest with no size allows 256 MiB | [Bring your own storage](guides/bring-your-own-storage.md) | | Read-back check after an upload | a full download and SHA-256 up to 16 MiB; larger packs get a size check and byte-exact head and tail ranges | same | diff --git a/docs/schemas/README.md b/docs/schemas/README.md index 4235f0f10..e32d3ad9c 100644 --- a/docs/schemas/README.md +++ b/docs/schemas/README.md @@ -22,6 +22,17 @@ The exit code says which schema applies: 0, the command's own; anything else, th | `dg auth name register` | [`auth-name-register.schema.json`](dg/auth-name-register.schema.json) | | `dg auth new` | [`auth-new.schema.json`](dg/auth-new.schema.json) | | `dg auth status` | [`auth-status.schema.json`](dg/auth-status.schema.json) | +| `dg board add` | [`board-add.schema.json`](dg/board-add.schema.json) | +| `dg board archive` | [`board-archive.schema.json`](dg/board-archive.schema.json) | +| `dg board close` | [`board-close.schema.json`](dg/board-close.schema.json) | +| `dg board create` | [`board-create.schema.json`](dg/board-create.schema.json) | +| `dg board delete` | [`board-delete.schema.json`](dg/board-delete.schema.json) | +| `dg board list` | [`board-list.schema.json`](dg/board-list.schema.json) | +| `dg board move` | [`board-move.schema.json`](dg/board-move.schema.json) | +| `dg board next-iteration` | [`board-next-iteration.schema.json`](dg/board-next-iteration.schema.json) | +| `dg board remove` | [`board-remove.schema.json`](dg/board-remove.schema.json) | +| `dg board set` | [`board-set.schema.json`](dg/board-set.schema.json) | +| `dg board view` | [`board-view.schema.json`](dg/board-view.schema.json) | | `dg bot allow` | [`bot-allow.schema.json`](dg/bot-allow.schema.json) | | `dg bot ask` | [`bot-ask.schema.json`](dg/bot-ask.schema.json) | | `dg bot jobs` | [`bot-jobs.schema.json`](dg/bot-jobs.schema.json) | diff --git a/docs/schemas/dg/board-add.schema.json b/docs/schemas/dg/board-add.schema.json new file mode 100644 index 000000000..d8966ccaf --- /dev/null +++ b/docs/schemas/dg/board-add.schema.json @@ -0,0 +1,168 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://raw.githubusercontent.com/PastaPastaPasta/dash-forge/master/docs/schemas/dg/board-add.schema.json", + "title": "dg board add --json", + "description": "Items put on a board, or a new issue opened there (`--title`).", + "type": "object", + "properties": { + "schemaVersion": { + "const": 1 + }, + "status": { + "type": "string" + }, + "board": { + "type": "integer" + }, + "count": { + "type": "integer" + }, + "cards": { + "type": "array", + "items": { + "type": "object", + "properties": { + "item": { + "type": "string" + }, + "label": { + "type": "string" + }, + "documentId": { + "type": "string" + }, + "created": { + "type": "boolean" + }, + "changed": { + "type": "boolean" + }, + "col": { + "type": [ + "integer", + "null" + ] + }, + "rank": { + "type": [ + "string", + "null" + ] + }, + "state": { + "type": "string", + "enum": [ + "active", + "archived", + "removed" + ] + } + }, + "required": [ + "item", + "documentId", + "state" + ] + } + }, + "failed": { + "anyOf": [ + { + "type": "object", + "properties": { + "item": { + "type": "string" + }, + "error": { + "type": "string" + } + }, + "required": [ + "item" + ] + }, + { + "type": "null" + } + ] + }, + "skipped": { + "type": "array", + "items": { + "type": "string" + } + }, + "cost": { + "$ref": "common.schema.json#/$defs/cost" + }, + "issue": { + "type": "object", + "properties": { + "number": { + "type": "integer" + }, + "id": { + "type": "string" + } + }, + "required": [ + "number", + "id" + ] + }, + "column": { + "type": "string" + }, + "card": { + "type": "object", + "properties": { + "item": { + "type": "string" + }, + "label": { + "type": "string" + }, + "documentId": { + "type": "string" + }, + "created": { + "type": "boolean" + }, + "changed": { + "type": "boolean" + }, + "col": { + "type": [ + "integer", + "null" + ] + }, + "rank": { + "type": [ + "string", + "null" + ] + }, + "state": { + "type": "string", + "enum": [ + "active", + "archived", + "removed" + ] + } + }, + "required": [ + "item", + "documentId", + "state" + ] + } + }, + "required": [ + "schemaVersion", + "status", + "board" + ], + "additionalProperties": true +} diff --git a/docs/schemas/dg/board-archive.schema.json b/docs/schemas/dg/board-archive.schema.json new file mode 100644 index 000000000..72ec9d2a1 --- /dev/null +++ b/docs/schemas/dg/board-archive.schema.json @@ -0,0 +1,106 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://raw.githubusercontent.com/PastaPastaPasta/dash-forge/master/docs/schemas/dg/board-archive.schema.json", + "title": "dg board archive --json", + "description": "Items archived on a board, or restored.", + "type": "object", + "properties": { + "schemaVersion": { + "const": 1 + }, + "status": { + "type": "string" + }, + "board": { + "type": "integer" + }, + "count": { + "type": "integer" + }, + "cards": { + "type": "array", + "items": { + "type": "object", + "properties": { + "item": { + "type": "string" + }, + "label": { + "type": "string" + }, + "documentId": { + "type": "string" + }, + "created": { + "type": "boolean" + }, + "changed": { + "type": "boolean" + }, + "col": { + "type": [ + "integer", + "null" + ] + }, + "rank": { + "type": [ + "string", + "null" + ] + }, + "state": { + "type": "string", + "enum": [ + "active", + "archived", + "removed" + ] + } + }, + "required": [ + "item", + "documentId", + "state" + ] + } + }, + "failed": { + "anyOf": [ + { + "type": "object", + "properties": { + "item": { + "type": "string" + }, + "error": { + "type": "string" + } + }, + "required": [ + "item" + ] + }, + { + "type": "null" + } + ] + }, + "skipped": { + "type": "array", + "items": { + "type": "string" + } + }, + "cost": { + "$ref": "common.schema.json#/$defs/cost" + } + }, + "required": [ + "schemaVersion", + "status", + "board", + "count" + ], + "additionalProperties": true +} diff --git a/docs/schemas/dg/board-close.schema.json b/docs/schemas/dg/board-close.schema.json new file mode 100644 index 000000000..bd823c954 --- /dev/null +++ b/docs/schemas/dg/board-close.schema.json @@ -0,0 +1,38 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://raw.githubusercontent.com/PastaPastaPasta/dash-forge/master/docs/schemas/dg/board-close.schema.json", + "title": "dg board close --json", + "description": "A board closed or reopened.", + "type": "object", + "properties": { + "schemaVersion": { + "const": 1 + }, + "status": { + "type": "string", + "enum": [ + "closed", + "reopened", + "deleted" + ] + }, + "key": { + "type": "integer" + }, + "documentId": { + "type": "string" + }, + "changed": { + "type": "boolean" + }, + "cost": { + "$ref": "common.schema.json#/$defs/cost" + } + }, + "required": [ + "schemaVersion", + "status", + "key" + ], + "additionalProperties": true +} diff --git a/docs/schemas/dg/board-create.schema.json b/docs/schemas/dg/board-create.schema.json new file mode 100644 index 000000000..88589be0d --- /dev/null +++ b/docs/schemas/dg/board-create.schema.json @@ -0,0 +1,47 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://raw.githubusercontent.com/PastaPastaPasta/dash-forge/master/docs/schemas/dg/board-create.schema.json", + "title": "dg board create --json", + "description": "A board created (`exists`: an earlier run of the same create had already made it).", + "type": "object", + "properties": { + "schemaVersion": { + "const": 1 + }, + "status": { + "type": "string", + "enum": [ + "created", + "exists" + ] + }, + "key": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "documentId": { + "type": "string" + }, + "id": { + "type": "string" + }, + "columns": { + "type": "array", + "items": { + "type": "string" + } + }, + "cost": { + "$ref": "common.schema.json#/$defs/cost" + } + }, + "required": [ + "schemaVersion", + "status", + "key", + "documentId" + ], + "additionalProperties": true +} diff --git a/docs/schemas/dg/board-delete.schema.json b/docs/schemas/dg/board-delete.schema.json new file mode 100644 index 000000000..d2ceb740d --- /dev/null +++ b/docs/schemas/dg/board-delete.schema.json @@ -0,0 +1,38 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://raw.githubusercontent.com/PastaPastaPasta/dash-forge/master/docs/schemas/dg/board-delete.schema.json", + "title": "dg board delete --json", + "description": "A board deleted.", + "type": "object", + "properties": { + "schemaVersion": { + "const": 1 + }, + "status": { + "type": "string", + "enum": [ + "closed", + "reopened", + "deleted" + ] + }, + "key": { + "type": "integer" + }, + "documentId": { + "type": "string" + }, + "changed": { + "type": "boolean" + }, + "cost": { + "$ref": "common.schema.json#/$defs/cost" + } + }, + "required": [ + "schemaVersion", + "status", + "key" + ], + "additionalProperties": true +} diff --git a/docs/schemas/dg/board-list.schema.json b/docs/schemas/dg/board-list.schema.json new file mode 100644 index 000000000..a29798113 --- /dev/null +++ b/docs/schemas/dg/board-list.schema.json @@ -0,0 +1,82 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://raw.githubusercontent.com/PastaPastaPasta/dash-forge/master/docs/schemas/dg/board-list.schema.json", + "title": "dg board list --json", + "description": "The repository's boards.", + "type": "object", + "properties": { + "schemaVersion": { + "const": 1 + }, + "count": { + "type": "integer" + }, + "boards": { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "type": "integer" + }, + "name": { + "type": [ + "string", + "null" + ] + }, + "state": { + "type": "string", + "enum": [ + "open", + "closed", + "deleted" + ] + }, + "sealed": { + "type": "boolean" + }, + "repoId": { + "type": "string" + }, + "columns": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "null" + } + ] + }, + "specError": { + "type": [ + "string", + "null" + ], + "description": "Why the definition is not shown: a refusal of the board rules, or `unreadable` (sealed)." + }, + "updatedAt": { + "type": "integer" + }, + "editedBy": { + "type": "string" + } + }, + "required": [ + "key", + "state" + ] + } + } + }, + "required": [ + "schemaVersion", + "count", + "boards" + ], + "additionalProperties": true +} diff --git a/docs/schemas/dg/board-move.schema.json b/docs/schemas/dg/board-move.schema.json new file mode 100644 index 000000000..0fbca7b59 --- /dev/null +++ b/docs/schemas/dg/board-move.schema.json @@ -0,0 +1,79 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://raw.githubusercontent.com/PastaPastaPasta/dash-forge/master/docs/schemas/dg/board-move.schema.json", + "title": "dg board move --json", + "description": "An item moved on a board.", + "type": "object", + "properties": { + "schemaVersion": { + "const": 1 + }, + "status": { + "type": "string", + "enum": [ + "moved" + ] + }, + "board": { + "type": "integer" + }, + "column": { + "type": "string" + }, + "card": { + "type": "object", + "properties": { + "item": { + "type": "string" + }, + "label": { + "type": "string" + }, + "documentId": { + "type": "string" + }, + "created": { + "type": "boolean" + }, + "changed": { + "type": "boolean" + }, + "col": { + "type": [ + "integer", + "null" + ] + }, + "rank": { + "type": [ + "string", + "null" + ] + }, + "state": { + "type": "string", + "enum": [ + "active", + "archived", + "removed" + ] + } + }, + "required": [ + "item", + "documentId", + "state" + ] + }, + "cost": { + "$ref": "common.schema.json#/$defs/cost" + } + }, + "required": [ + "schemaVersion", + "status", + "board", + "card" + ], + "additionalProperties": true +} diff --git a/docs/schemas/dg/board-next-iteration.schema.json b/docs/schemas/dg/board-next-iteration.schema.json new file mode 100644 index 000000000..358aa9630 --- /dev/null +++ b/docs/schemas/dg/board-next-iteration.schema.json @@ -0,0 +1,109 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://raw.githubusercontent.com/PastaPastaPasta/dash-forge/master/docs/schemas/dg/board-next-iteration.schema.json", + "title": "dg board next-iteration --json", + "description": "The current iteration's open items moved into the next.", + "type": "object", + "properties": { + "schemaVersion": { + "const": 1 + }, + "status": { + "type": "string" + }, + "board": { + "type": "integer" + }, + "count": { + "type": "integer" + }, + "cards": { + "type": "array", + "items": { + "type": "object", + "properties": { + "item": { + "type": "string" + }, + "label": { + "type": "string" + }, + "documentId": { + "type": "string" + }, + "created": { + "type": "boolean" + }, + "changed": { + "type": "boolean" + }, + "col": { + "type": [ + "integer", + "null" + ] + }, + "rank": { + "type": [ + "string", + "null" + ] + }, + "state": { + "type": "string", + "enum": [ + "active", + "archived", + "removed" + ] + } + }, + "required": [ + "item", + "documentId", + "state" + ] + } + }, + "failed": { + "anyOf": [ + { + "type": "object", + "properties": { + "item": { + "type": "string" + }, + "error": { + "type": "string" + } + }, + "required": [ + "item" + ] + }, + { + "type": "null" + } + ] + }, + "skipped": { + "type": "array", + "items": { + "type": "string" + } + }, + "cost": { + "$ref": "common.schema.json#/$defs/cost" + }, + "iteration": { + "type": "string" + } + }, + "required": [ + "schemaVersion", + "status", + "board", + "count" + ], + "additionalProperties": true +} diff --git a/docs/schemas/dg/board-remove.schema.json b/docs/schemas/dg/board-remove.schema.json new file mode 100644 index 000000000..0b2944e45 --- /dev/null +++ b/docs/schemas/dg/board-remove.schema.json @@ -0,0 +1,106 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://raw.githubusercontent.com/PastaPastaPasta/dash-forge/master/docs/schemas/dg/board-remove.schema.json", + "title": "dg board remove --json", + "description": "Items removed from a board.", + "type": "object", + "properties": { + "schemaVersion": { + "const": 1 + }, + "status": { + "type": "string" + }, + "board": { + "type": "integer" + }, + "count": { + "type": "integer" + }, + "cards": { + "type": "array", + "items": { + "type": "object", + "properties": { + "item": { + "type": "string" + }, + "label": { + "type": "string" + }, + "documentId": { + "type": "string" + }, + "created": { + "type": "boolean" + }, + "changed": { + "type": "boolean" + }, + "col": { + "type": [ + "integer", + "null" + ] + }, + "rank": { + "type": [ + "string", + "null" + ] + }, + "state": { + "type": "string", + "enum": [ + "active", + "archived", + "removed" + ] + } + }, + "required": [ + "item", + "documentId", + "state" + ] + } + }, + "failed": { + "anyOf": [ + { + "type": "object", + "properties": { + "item": { + "type": "string" + }, + "error": { + "type": "string" + } + }, + "required": [ + "item" + ] + }, + { + "type": "null" + } + ] + }, + "skipped": { + "type": "array", + "items": { + "type": "string" + } + }, + "cost": { + "$ref": "common.schema.json#/$defs/cost" + } + }, + "required": [ + "schemaVersion", + "status", + "board", + "count" + ], + "additionalProperties": true +} diff --git a/docs/schemas/dg/board-set.schema.json b/docs/schemas/dg/board-set.schema.json new file mode 100644 index 000000000..15b13ac96 --- /dev/null +++ b/docs/schemas/dg/board-set.schema.json @@ -0,0 +1,79 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://raw.githubusercontent.com/PastaPastaPasta/dash-forge/master/docs/schemas/dg/board-set.schema.json", + "title": "dg board set --json", + "description": "An item's fields set on a board.", + "type": "object", + "properties": { + "schemaVersion": { + "const": 1 + }, + "status": { + "type": "string", + "enum": [ + "set" + ] + }, + "board": { + "type": "integer" + }, + "fields": { + "type": "object" + }, + "card": { + "type": "object", + "properties": { + "item": { + "type": "string" + }, + "label": { + "type": "string" + }, + "documentId": { + "type": "string" + }, + "created": { + "type": "boolean" + }, + "changed": { + "type": "boolean" + }, + "col": { + "type": [ + "integer", + "null" + ] + }, + "rank": { + "type": [ + "string", + "null" + ] + }, + "state": { + "type": "string", + "enum": [ + "active", + "archived", + "removed" + ] + } + }, + "required": [ + "item", + "documentId", + "state" + ] + }, + "cost": { + "$ref": "common.schema.json#/$defs/cost" + } + }, + "required": [ + "schemaVersion", + "status", + "board", + "card" + ], + "additionalProperties": true +} diff --git a/docs/schemas/dg/board-view.schema.json b/docs/schemas/dg/board-view.schema.json new file mode 100644 index 000000000..c36076688 --- /dev/null +++ b/docs/schemas/dg/board-view.schema.json @@ -0,0 +1,288 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://raw.githubusercontent.com/PastaPastaPasta/dash-forge/master/docs/schemas/dg/board-view.schema.json", + "title": "dg board view --json", + "description": "A board: its columns (or the view's groups) with their items, totals and work-in-progress limits; every item with where it shows; and `fold`, the placement both clients compute (docs/design/boards.md §2.4).", + "type": "object", + "properties": { + "schemaVersion": { + "const": 1 + }, + "board": { + "type": "object", + "properties": { + "key": { + "type": "integer" + }, + "name": { + "type": [ + "string", + "null" + ] + }, + "state": { + "type": "string", + "enum": [ + "open", + "closed", + "deleted" + ] + }, + "sealed": { + "type": "boolean" + }, + "repoId": { + "type": "string" + }, + "columns": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "null" + } + ] + }, + "specError": { + "type": [ + "string", + "null" + ], + "description": "Why the definition is not shown: a refusal of the board rules, or `unreadable` (sealed)." + }, + "updatedAt": { + "type": "integer" + }, + "editedBy": { + "type": "string" + } + }, + "required": [ + "key", + "state" + ] + }, + "view": { + "type": [ + "string", + "null" + ] + }, + "groupBy": { + "type": "string" + }, + "sumField": { + "type": [ + "string", + "null" + ] + }, + "now": { + "type": "integer" + }, + "columns": { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": {}, + "name": { + "type": "string" + }, + "count": { + "type": "integer" + }, + "sum": {}, + "wip": { + "type": [ + "integer", + "null" + ] + }, + "over": { + "type": "boolean" + }, + "items": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "name", + "count", + "items" + ] + } + }, + "items": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "number": { + "type": "integer" + }, + "repoId": { + "type": "string" + }, + "repo": { + "type": [ + "string", + "null" + ] + }, + "kind": { + "type": "string", + "enum": [ + "issue", + "pr" + ] + }, + "state": { + "type": "string", + "enum": [ + "open", + "closed", + "merged" + ] + }, + "title": { + "type": "string" + }, + "labels": { + "type": "array", + "items": { + "type": "string" + } + }, + "assignees": { + "type": "array", + "items": { + "type": "string" + } + }, + "milestone": { + "type": [ + "string", + "null" + ] + }, + "author": { + "type": "string" + }, + "closedAt": { + "type": [ + "integer", + "null" + ] + }, + "hidden": { + "type": "boolean" + }, + "on": { + "type": "boolean" + }, + "shown": { + "type": "boolean" + }, + "column": { + "type": [ + "string", + "null" + ] + }, + "col": { + "type": [ + "integer", + "null" + ] + }, + "rank": { + "type": [ + "string", + "null" + ] + }, + "archived": { + "anyOf": [ + { + "type": "string", + "enum": [ + "card", + "auto" + ] + }, + { + "type": "null" + } + ] + }, + "removed": { + "type": "boolean" + }, + "fields": { + "type": "object" + } + }, + "required": [ + "id", + "number", + "kind", + "state" + ] + } + }, + "progress": { + "type": [ + "object", + "null" + ] + }, + "unresolved": { + "type": "array", + "items": { + "type": "string" + } + }, + "hidden": { + "type": "array", + "items": { + "type": "string" + } + }, + "missing": { + "type": "array", + "items": { + "type": "string" + } + }, + "partial": { + "type": "boolean" + }, + "hasOlderClosed": { + "type": "boolean" + }, + "fold": { + "type": [ + "object", + "null" + ] + } + }, + "required": [ + "schemaVersion", + "board", + "columns", + "items" + ], + "additionalProperties": true +} diff --git a/docs/schemas/dg/index.json b/docs/schemas/dg/index.json index 8d58ea7f4..e0296ca46 100644 --- a/docs/schemas/dg/index.json +++ b/docs/schemas/dg/index.json @@ -12,6 +12,17 @@ "auth name register": "auth-name-register.schema.json", "auth new": "auth-new.schema.json", "auth status": "auth-status.schema.json", + "board add": "board-add.schema.json", + "board archive": "board-archive.schema.json", + "board close": "board-close.schema.json", + "board create": "board-create.schema.json", + "board delete": "board-delete.schema.json", + "board list": "board-list.schema.json", + "board move": "board-move.schema.json", + "board next-iteration": "board-next-iteration.schema.json", + "board remove": "board-remove.schema.json", + "board set": "board-set.schema.json", + "board view": "board-view.schema.json", "bot allow": "bot-allow.schema.json", "bot ask": "bot-ask.schema.json", "bot jobs": "bot-jobs.schema.json", diff --git a/docs/schemas/generate.py b/docs/schemas/generate.py index 59830ef41..a274ebc44 100644 --- a/docs/schemas/generate.py +++ b/docs/schemas/generate.py @@ -559,6 +559,56 @@ def write_result(extra, req=('status',)): cmd('milestone create', 'A milestone defined.', MS, ['status', 'title']) cmd('milestone close', 'A milestone closed.', MS, ['status', 'title']) +# -- boards (docs/design/boards.md §6) -------------------------------------------------------- +BOARD = O({ + 'key': I, 'name': nl(S), 'state': E('open', 'closed', 'deleted'), 'sealed': B, 'repoId': S, 'columns': nl(SA), + 'specError': D('Why the definition is not shown: a refusal of the board rules, or `unreadable` (sealed).', nl(S)), + 'updatedAt': I, 'editedBy': S, +}, ['key', 'state']) +CARD = O({ + 'item': S, 'label': S, 'documentId': S, 'created': B, 'changed': B, 'col': nl(I), 'rank': nl(S), + 'state': E('active', 'archived', 'removed'), +}, ['item', 'documentId', 'state']) +cmd('board list', 'The repository\'s boards.', {'count': I, 'boards': A(BOARD)}, ['count', 'boards']) +cmd('board view', 'A board: its columns (or the view\'s groups) with their items, totals and work-in-progress limits; ' + 'every item with where it shows; and `fold`, the placement both clients compute (docs/design/boards.md §2.4).', { + 'board': BOARD, 'view': nl(S), 'groupBy': S, 'sumField': nl(S), 'now': I, + 'columns': A(O({'key': ANY, 'name': S, 'count': I, 'sum': ANY, 'wip': nl(I), 'over': B, 'items': SA}, + ['name', 'count', 'items'])), + 'items': A(O({ + 'id': S, 'number': I, 'repoId': S, 'repo': nl(S), 'kind': E('issue', 'pr'), 'state': E('open', 'closed', 'merged'), + 'title': S, 'labels': SA, 'assignees': SA, 'milestone': nl(S), 'author': S, 'closedAt': nl(I), 'hidden': B, + 'on': B, 'shown': B, 'column': nl(S), 'col': nl(I), 'rank': nl(S), 'archived': nl(E('card', 'auto')), + 'removed': B, 'fields': OBJ, + }, ['id', 'number', 'kind', 'state'])), + 'progress': nl(OBJ), 'unresolved': SA, 'hidden': SA, 'missing': SA, 'partial': B, 'hasOlderClosed': B, + 'fold': nl(OBJ), +}, ['board', 'columns', 'items']) +cmd('board create', 'A board created (`exists`: an earlier run of the same create had already made it).', { + 'status': E('created', 'exists'), 'key': I, 'name': S, 'documentId': S, 'id': S, 'columns': SA, 'cost': COST, +}, ['status', 'key', 'documentId']) +BOARD_STATE = {'status': E('closed', 'reopened', 'deleted'), 'key': I, 'documentId': S, 'changed': B, 'cost': COST} +cmd('board close', 'A board closed or reopened.', BOARD_STATE, ['status', 'key']) +cmd('board delete', 'A board deleted.', BOARD_STATE, ['status', 'key']) +cmd('board move', 'An item moved on a board.', { + 'status': E('moved'), 'board': I, 'column': S, 'card': CARD, 'cost': COST, +}, ['status', 'board', 'card']) +cmd('board set', 'An item\'s fields set on a board.', { + 'status': E('set'), 'board': I, 'fields': OBJ, 'card': CARD, 'cost': COST, +}, ['status', 'board', 'card']) +BOARD_BULK = { + 'status': S, 'board': I, 'count': I, 'cards': A(CARD), 'failed': nl(O({'item': S, 'error': S}, ['item'])), + 'skipped': SA, 'cost': COST, +} +cmd('board add', 'Items put on a board, or a new issue opened there (`--title`).', { + **BOARD_BULK, 'issue': O({'number': I, 'id': S}, ['number', 'id']), 'column': S, 'card': CARD, +}, ['status', 'board']) +cmd('board archive', 'Items archived on a board, or restored.', BOARD_BULK, ['status', 'board', 'count']) +cmd('board remove', 'Items removed from a board.', BOARD_BULK, ['status', 'board', 'count']) +cmd('board next-iteration', 'The current iteration\'s open items moved into the next.', { + **BOARD_BULK, 'iteration': S, +}, ['status', 'board', 'count']) + # -- profile, signing keys, collaborators ----------------------------------------------------- cmd('profile show', 'An identity\'s public profile.', { 'identityId': S, 'profile': nl(OBJ), diff --git a/docs/security/private-repos.md b/docs/security/private-repos.md index 559dc6b73..f010a2c58 100644 --- a/docs/security/private-repos.md +++ b/docs/security/private-repos.md @@ -230,14 +230,15 @@ The plaintext is a sequence of records `tag(u8) ‖ len(u16) ‖ value`. No JSON | 25 | a letter's recipient identity id, **repeatable**, consecutive, in slot order | bytes | `enc` v0x04 only (§4.1) | exactly 32 B each | | 27 | the salt of the document's OID blinds | bytes | `enc` **v0x03** only, beside 22, 23 or 24 and present exactly when one of them is (§19.1); reserved everywhere else | exactly 32 B | | 29 | a letter's role group: `0x01` Maintainers, `0x02` Writers and maintainers; at most once, after the tag-25 records | one byte | `enc` v0x04 only (§17.7) | exactly 1 B, value 1 or 2 | -| 64 | padding | zero bytes | members-only and specific-people documents (§4.1) | skipped | +| 32–36 | a board's `name` (32) and `spec` (33); a card's `col` (34), `rank` (35) and `f` (36) | see §4.6 | `board` and `card` only (UPDATE-3) | §4.6 | +| 64 | padding | zero bytes | members-only and specific-people documents (§4.1); sealed releases, boards and cards (§16.2, §4.6) | skipped | | 65 | seal-off marker | bytes | interpreted in `config` only; skipped in other kinds | 30 B fresh, 34 B start-over; §18.5 | **Strictness** (any violation is `Malformed`): - Records are in strictly ascending tag order, except that consecutive tag-7 records repeat, and so do consecutive tag-25 records in a letter; any other repeated tag is malformed (two padding records included, `mixed_doc_open__pad_twice_refused`). - A record whose declared `len` runs past the end of the plaintext, or fewer than 3 trailing bytes after the last complete record, is malformed. There are no padding bytes outside records: padding is the tag-64 record of §4.1, which, as an extension record, comes after every other record. -- Tags 22–63 are **reserved**: a record with one is malformed. Three exceptions are defined: **tags 25 and 29** are fields of `enc` v0x04 only (in v0x01 and v0x03 they are still reserved, `mixed_doc_open__recipient_tag_refused`, `mixed_doc_open__group_tag_refused`; in a letter tag 29 is one byte, 1 or 2, at most once, after the recipients, `named_envelope_open__group_*`), and tags **22–24 and 27** are fields of `enc` v0x03 members-only ref updates, PRs and head updates (§19): in v0x01, v0x04 and every other kind they stay reserved (`sealed_ref__open_v01_blind_tags_reserved`, `mixed_doc_open__blind_tags_reserved`), and a client from before §19 refuses such a document as malformed instead of folding its blinds as commits (DESIGN S5 V5). An event carries a value (15), a head (24), or both. Tags 64–255 are **extension** tags: a reader skips them (forward compatibility), except tag 65 in a `config`, the seal-off marker (§18.5). Tag 64 is the padding record. Unknown tag-65 values in configs are retained so their epoch still supplies a boundary. (Tags 16–21 were reserved before §16; they are release-only, so in every other kind they are still malformed, as "not listed for the kind" below.) +- Tags 22–63 are **reserved**: a record with one is malformed. Three exceptions are defined: **tags 25 and 29** are fields of `enc` v0x04 only (in v0x01 and v0x03 they are still reserved, `mixed_doc_open__recipient_tag_refused`, `mixed_doc_open__group_tag_refused`; in a letter tag 29 is one byte, 1 or 2, at most once, after the recipients, `named_envelope_open__group_*`), and tags **22–24 and 27** are fields of `enc` v0x03 members-only ref updates, PRs and head updates (§19): in v0x01, v0x04 and every other kind they stay reserved (`sealed_ref__open_v01_blind_tags_reserved`, `mixed_doc_open__blind_tags_reserved`), and a client from before §19 refuses such a document as malformed instead of folding its blinds as commits (DESIGN S5 V5). An event carries a value (15), a head (24), or both. Tags 64–255 are **extension** tags: a reader skips them (forward compatibility), except tag 65 in a `config`, the seal-off marker (§18.5). Tag 64 is the padding record. Unknown tag-65 values in configs are retained so their epoch still supplies a boundary. (Tags 16–21 were reserved before §16; they are release-only, so in every other kind they are still malformed, as "not listed for the kind" below.) Likewise tags 32–36 are the board's and the card's (§4.6) and malformed in every other kind. - A tag not listed for the document's kind (tag 3 in an issue, say) is malformed. Tags 11 and 12 are allowed only in a config with `e ≥ 1` (never epoch 0); tag 11's only value is the one byte `0x01`. A **burned** config (tag 11) carries `prevEpoch` but neither `prevEpochKey` nor `skipEpochKey`: its key may sit with someone who never held the key below it. - Every UTF-8 value must be valid UTF-8, within the cap above, and non-empty unless the cap says otherwise; a zero-length record for a field with `minLength 1` counts as absent. Fixed-size tags must be exactly their size. - Required fields by kind: issue/patch `title`; comment `body`; event `eventValue` (an event without a value is not sealed, see §7), or in `enc` v0x03 a head (24) instead (a members-only PR's head update, §19.4); refUpdate/protectedRefUpdate `refName`; every config with `e ≥ 1`, anchor or not, `prevEpoch`, and unless burned `prevEpochKey` (neither is allowed when `e = 0`): any config of an epoch can become its anchor when an earlier one's author stops being a maintainer (§5.3), and it must then still chain to the previous epoch, so a writer copies the anchor's whole chain link (`prevEpoch`, `prevEpochKey`, `skipEpochKey`, the burned flag) into every later config of the epoch; review and epoch-0 config have none. An empty plaintext is therefore valid only for a review or an epoch-0 non-anchor config. @@ -249,7 +250,7 @@ The plaintext is a sequence of records `tag(u8) ‖ len(u16) ‖ value`. No JSON AD = "dash-forge/v2/doc" ‖ 0x00 ‖ enc[0] ‖ repoId(32) ‖ $ownerId(32) ‖ u32(epoch) ‖ docType(ASCII) ‖ 0x00 ‖ bind ``` -`enc[0]` is the version byte (`0x01` to `0x04`), so a ciphertext cannot be re-framed under another version. A specific-people letter (v0x04) has no epoch keys: its AD is built from `repoId` alone with the literal `epoch = 0`, and is then extended to `AD'` by `SHA-256(H)` (§4.1); a config, whose bind is `COMMIT_e`, has no such AD. `docType` is the contract's type name (`issue`, `patch`, `comment`, `review`, `event`, `authorEvent`, `refUpdate`, `protectedRefUpdate`, `config`, `release`). An `authorEvent` (an issue's or PR's author's own event) is sealed only where the contract declares `authorEvent.enc` (mainnet M3): its value (a retarget's new base) is TLV 15 as an event's, never a head (`private_collab_seal__author_event_retarget`). `bind` is the type's immutable plaintext identity: +`enc[0]` is the version byte (`0x01` to `0x04`), so a ciphertext cannot be re-framed under another version. A specific-people letter (v0x04) has no epoch keys: its AD is built from `repoId` alone with the literal `epoch = 0`, and is then extended to `AD'` by `SHA-256(H)` (§4.1); a config, whose bind is `COMMIT_e`, has no such AD. `docType` is the contract's type name (`issue`, `patch`, `comment`, `review`, `event`, `authorEvent`, `refUpdate`, `protectedRefUpdate`, `config`, `release`, and forge-meta's `board` and `card`, UPDATE-3). An `authorEvent` (an issue's or PR's author's own event) is sealed only where the contract declares `authorEvent.enc` (mainnet M3): its value (a retarget's new base) is TLV 15 as an event's, never a head (`private_collab_seal__author_event_retarget`). `bind` is the type's immutable plaintext identity: | type | bind | |---|---| @@ -259,8 +260,29 @@ AD = "dash-forge/v2/doc" ‖ 0x00 ‖ enc[0] ‖ repoId(32) ‖ $ownerId(32) ‖ | refUpdate, protectedRefUpdate | `refNameHash` (32) ‖ `oidf(newOid)` ‖ `oidf(prevOid or empty)` ‖ `force` (0x00/0x01) | | config | `COMMIT_e` (32) | | release | the document's `tagName` string, as its 43 ASCII bytes (§16.2) | +| board | `u32(key)` (the board's `name` and `spec` sealed together; [boards.md](../design/boards.md) §3.3) | +| card | `u32(board)` ‖ `item` (32) (the card's `col`, `rank` and `f` sealed; its `state` stays plaintext) | -`oidf(x) = u8(len(x)) ‖ x`. Binding `repoId`, `$ownerId`, `epoch` and the type means a ciphertext lifted from one document cannot be replayed as another: not by an outsider into a new comment in the same repo (different `$ownerId`), not into another repo, not under another type or epoch. `$ownerId` is safe to bind because these nine types are not transferable; making one transferable would be a breaking change to this design. The ref-update binding ties the hidden name to the visible tip, so a stored `enc` cannot be re-used to name a different ref for the same OID. The document's `$id`, `$createdAt` and `$createdAtBlockHeight` are not bound (unknown at encryption time). +`oidf(x) = u8(len(x)) ‖ x`. Binding `repoId`, `$ownerId`, `epoch` and the type means a ciphertext lifted from one document cannot be replayed as another: not by an outsider into a new comment in the same repo (different `$ownerId`), not into another repo, not under another type or epoch. `$ownerId` is safe to bind because none of these types is transferable; making one transferable would be a breaking change to this design. The ref-update binding ties the hidden name to the visible tip, so a stored `enc` cannot be re-used to name a different ref for the same OID. A board's or a card's binding is its immutable keys, so a sealed payload cannot be moved to another board or item; both are mutable, and a member's edit re-seals the whole payload under the repository's current epoch (a card is one document per member, item and board, so a replace is its only way to change). The document's `$id`, `$createdAt` and `$createdAtBlockHeight` are not bound (unknown at encryption time). + +### 4.6 Boards and cards (UPDATE-3) + +A private repository's `board` and `card` documents ([boards.md](../design/boards.md) §3.3) seal their content into `enc` **v0x01** under the repository's current write epoch, with the AD of §4.4 (`docType` `board`, `bind = u32(key)`; `docType` `card`, `bind = u32(board) ‖ item (32)`). Both types are mutable, one document per member, and every save re-seals the whole payload under the epoch current then (a replace sets `enc`, `epoch` and the plaintext `state` and `r`). `enc` caps: 5120 bytes for a board, 2560 for a card (forge-meta `board.enc` / `card.enc` `maxItems`), so 5091 and 2531 bytes of TLV. + +| tag | field | type | in | cap (the plaintext schema's) | +|---|---|---|---|---| +| 32 | `name` | UTF-8 | board, **required** | 1–63 chars, ≤ 252 B, no control character, at least one character that is not white space | +| 33 | `spec` | UTF-8 (the definition's JSON, boards.md §2.7) | board, **required** | 1–4096 B | +| 34 | `col` | one byte, 0–255 | card | exactly 1 B | +| 35 | `rank` | ASCII | card | 1–63 B, `^[0-9A-Za-z]*[1-9A-Za-z]$` | +| 36 | `f` | UTF-8 (the field values' JSON) | card | 1–2048 B | +| 64 | padding | zero bytes | both | the writer pads the TLV to a multiple of 32 bytes within the cap, as a release does (§16.2); readers skip it | + +The rules of §4.3 apply as written: records strictly ascending and none repeated; a tag 1–63 not listed for the kind (a card's tag in a board, tag 2 anywhere here) is malformed; 64–255 are skipped; a zero-length record of a text field counts as absent (so a board missing tag 32 or 33 is malformed); every value within its cap and valid UTF-8. A card may carry no record at all but the padding (an item archived or removed before it was ever placed). The TLV does not judge the JSON of `spec` and `f`: the board rules do, exactly as for a public board (a definition they refuse reads as a board with no definition; field values they drop read as none). + +**Reading** (in order): a document with `enc` that also carries a plaintext `name` / `spec` (board) or `col` / `rank` / `f` (card), with no `enc`, with no u32 `epoch`, or with an `enc` shorter than 29 bytes is `Malformed` (skipped, as every malformed document is); an `enc[0]` other than `0x01` is `Unreadable(UnknownVersion)` (a later client's, such as a public repository's members-only board in `enc` v0x03, boards.md §3.3: listed, never malformed); then `NoEpoch`, `NoKey`, AES-GCM (`BadTag`: the AD binds the repository, the signer, the epoch, the type and the board's key or the card's board and item, so a payload copied to another board, item, member or type fails), the TLV (`Malformed`), and the burned clause of §8.2 (`Late` for a document under a burned epoch whose signer is not a current member). The height part of the late-content rule does not apply: both types are member-gated at consensus on every create and replace, as a member `event` is. A board that does not open reads with no name or definition; a card that does not open keeps its plaintext `state` with no column, rank or fields (unknown, not empty: a writer applies its change to the newest card it can open). In a repository made public (§18) a sealed board or card is opened with the published keys; any other public repository's sealed one (a later client's members-only board) reads as unreadable. Neither is dropped, so newest-wins never brings an older revision back; and a writer finds its own document among the raw rows, so one it skips as malformed is still the one it replaces. + +Vectors `sealed_board__seal_*` and `sealed_board__open_*` (`tools/private-repos-vectors/boards.py`, an independent Python reference over this section; forge-web `lib/private/board.conformance.test.ts`, forge-core `private::board`). ### 4.5 Ref-name hashing, and the hash check on read @@ -511,6 +533,8 @@ New vector cases in `forge-contracts/vectors/` with `"rules": "v2"`, one file pe **`private_release_seal__*` / `private_release_open__*`**: sealed releases, listed in §16.7. +**`sealed_board__seal_*` / `sealed_board__open_*`**: a private repository's boards and cards, §4.6 (seal: the padded TLV, the AD and `enc` under the fixed inputs, or the writer's refusal; open: what a reader makes of a stored document, every failure of §4.6's order). + **`mixed_doc_seal__*` / `mixed_doc_open__*`** (members-only, `enc` v0x03; the fixed inputs above, `vis: "public"`): a comment on `targetId = 0x33×32` with body `members-only: the fix is in sec/cve-1` under `K_0` and the fixed nonce gives `K_obj = 4faf51f6930dfb44ded0de72f22d0bd0233a50c420b375ece2ce3edc56fb6958`, `COMMIT_obj = f9a7fa2b8dc201ec7c98681cdcfcfdd62d0c8514308e08b3254c75e528853e9f`, the padded TLV `0200256d656d626572732d6f6e6c793a207468652066697820697320696e207365632f6376652d31400015` followed by 21 zero bytes (64 B), and `enc` (125 B) `03000102030405060708090a0bf9a7fa2b8dc201ec7c98681cdcfcfdd62d0c8514308e08b3254c75e528853e9f68c2c84f9892eab0fdb7a611874cf68f179a64d1f255e203d2fcd039a43f1e5e4427ffea6920a5296635807834ce89db33640789703539675c630fe4e0e9e440fa0941eba61eeb6f2957e4f93ebbccfe`. The seal cases cover an issue, a review, an inline comment, a body at the v0x03 room (no padding record fits), an empty review (one bucket), an unpadded event, and the writer's refusals (a private header, a config, a body one byte over, a field not of the kind). The open cases: `member`, `outsider_placeholder` (no key: `NoKey`), `no_lane` (`NoEpoch`), `commit_mismatch`, `body_tampered` (`BadTag`), `forged_after_reveal_refused`, `moved_to_other_target`, `v01_relabelled_refused`, `v01_byte_relabelled_as_v03` (`CommitMismatch`), `v03_in_private_member` (readable, D38), `v03_too_short`, `pad_roundtrip`, `pad_mid_bucket`, `pad_twice_refused`, `pad_before_content_refused`, `recipient_tag_refused`, `blind_tags_reserved` (tag 22), `reserved_tag_23`, `reserved_tag_24`, `reserved_tag_27`, `late`, `v04_public` and `v04_private` (`Unreadable(Letter)`), `config_anchor_public`. **`oid_blind__*`, `sealed_ref__*`, `sealed_patch__*`** (members-only branches and pull requests, §19; `tools/private-repos-vectors/members_git.py`): the blind and its check; S5's PR scenarios in blind space (rule C across a rotation, a mismatched head update, a re-blinded commit that counts for no one); sealing and opening members-only ref updates (create, update, force, delete, protected, SHA-256 width, epoch 1) with every malformed shape and the blind alerts; the member fold's input over public and members-only updates of one name (S5 V1, V1b, V1c); members-only PRs from members-only and public sources, head updates, and their refusals. **`members_pack_plan__*`, `publish_guard__*`** are the git helper's (Rust only, §19.5, §19.6). diff --git a/forge-contracts/contracts/mainnet/forge-meta.json b/forge-contracts/contracts/mainnet/forge-meta.json index e5bb9c179..9cf56ef0c 100644 --- a/forge-contracts/contracts/mainnet/forge-meta.json +++ b/forge-contracts/contracts/mainnet/forge-meta.json @@ -748,6 +748,355 @@ "sealed" ], "additionalProperties": false + }, + "board": { + "type": "object", + "documentsMutable": true, + "canBeDeleted": false, + "ownerRefersTo": { + "anyOf": [ + { + "type": "deletableDocument", + "contractId": "FORGE_CORE_CONTRACT_ID", + "documentType": "maintainer", + "findBy": { + "repoId": "repoId", + "memberId": "." + } + }, + { + "type": "deletableDocument", + "contractId": "FORGE_CORE_CONTRACT_ID", + "documentType": "writer", + "findBy": { + "repoId": "repoId", + "memberId": "." + }, + "where": { + "role": "r" + } + } + ] + }, + "properties": { + "repoId": { + "$ref": "#/$defs/id", + "position": 0 + }, + "key": { + "type": "integer", + "minimum": 1, + "maximum": 4294967295, + "position": 1 + }, + "name": { + "type": "string", + "minLength": 1, + "maxLength": 63, + "maxBytes": 252, + "pattern": "^[^\\x00-\\x1f\\x7f]*[^\\s\\x00-\\x1f\\x7f][^\\x00-\\x1f\\x7f]*$", + "position": 2 + }, + "spec": { + "type": "string", + "minLength": 1, + "maxLength": 4096, + "maxBytes": 4096, + "position": 3 + }, + "state": { + "type": "integer", + "minimum": 0, + "maximum": 2, + "position": 4 + }, + "enc": { + "type": "array", + "byteArray": true, + "minItems": 29, + "maxItems": 5120, + "position": 5 + }, + "epoch": { + "type": "integer", + "minimum": 0, + "maximum": 4294967295, + "position": 6 + }, + "r": { + "type": "integer", + "minimum": 1, + "maximum": 1, + "position": 7 + } + }, + "immutable": [ + "repoId", + "key" + ], + "indices": [ + { + "name": "byKey", + "properties": [ + { + "repoId": "asc" + }, + { + "key": "asc" + }, + { + "$ownerId": "asc" + } + ], + "unique": true + } + ], + "required": [ + "$createdAt", + "$updatedAt", + "repoId", + "key", + "state", + "r" + ], + "additionalProperties": false, + "dependentRequired": { + "enc": [ + "epoch" + ] + }, + "propertyConstraints": { + "noPlain": { + "anyOf": [ + { + "absent": "enc" + }, + { + "allOf": [ + { + "absent": "name" + }, + { + "absent": "spec" + } + ] + } + ] + }, + "hasName": { + "anyOf": [ + { + "present": "enc" + }, + { + "allOf": [ + { + "present": "name" + }, + { + "present": "spec" + } + ] + } + ] + }, + "rClaim": { + "equal": [ + "r", + 1 + ] + } + } + }, + "card": { + "type": "object", + "documentsMutable": true, + "canBeDeleted": false, + "ownerRefersTo": { + "anyOf": [ + { + "type": "deletableDocument", + "contractId": "FORGE_CORE_CONTRACT_ID", + "documentType": "maintainer", + "findBy": { + "repoId": "repoId", + "memberId": "." + } + }, + { + "type": "deletableDocument", + "contractId": "FORGE_CORE_CONTRACT_ID", + "documentType": "writer", + "findBy": { + "repoId": "repoId", + "memberId": "." + }, + "where": { + "role": "r" + } + } + ] + }, + "properties": { + "repoId": { + "$ref": "#/$defs/id", + "position": 0 + }, + "board": { + "type": "integer", + "minimum": 1, + "maximum": 4294967295, + "position": 1 + }, + "item": { + "type": "identifier", + "refersTo": { + "anyOf": [ + { + "type": "permanentDocument", + "contractId": "FORGE_COLLAB_CONTRACT_ID", + "documentType": "issue" + }, + { + "type": "permanentDocument", + "contractId": "FORGE_COLLAB_CONTRACT_ID", + "documentType": "patch" + } + ] + }, + "position": 2 + }, + "col": { + "type": "integer", + "minimum": 0, + "maximum": 255, + "position": 3 + }, + "rank": { + "type": "string", + "minLength": 1, + "maxLength": 63, + "pattern": "^[0-9A-Za-z]*[1-9A-Za-z]$", + "position": 4 + }, + "f": { + "type": "string", + "minLength": 1, + "maxLength": 2048, + "maxBytes": 2048, + "position": 5 + }, + "state": { + "type": "integer", + "minimum": 0, + "maximum": 2, + "position": 6 + }, + "enc": { + "type": "array", + "byteArray": true, + "minItems": 29, + "maxItems": 2560, + "position": 7 + }, + "epoch": { + "type": "integer", + "minimum": 0, + "maximum": 4294967295, + "position": 8 + }, + "r": { + "type": "integer", + "minimum": 1, + "maximum": 2, + "position": 9 + } + }, + "immutable": [ + "repoId", + "board", + "item" + ], + "indices": [ + { + "name": "onItem", + "properties": [ + { + "item": "asc" + }, + { + "repoId": "asc" + }, + { + "board": "asc" + }, + { + "$ownerId": "asc" + } + ], + "unique": true + }, + { + "name": "recent", + "properties": [ + { + "repoId": "asc" + }, + { + "board": "asc" + }, + { + "$updatedAt": "asc" + } + ] + } + ], + "required": [ + "$createdAt", + "$updatedAt", + "repoId", + "board", + "item", + "state", + "r" + ], + "additionalProperties": false, + "dependentRequired": { + "enc": [ + "epoch" + ] + }, + "propertyConstraints": { + "noPlain": { + "anyOf": [ + { + "absent": "enc" + }, + { + "allOf": [ + { + "absent": "col" + }, + { + "absent": "rank" + }, + { + "absent": "f" + } + ] + } + ] + }, + "rClaim": { + "in": [ + "r", + [ + 1, + 2 + ] + ] + } + } } }, "config": { diff --git a/forge-contracts/deployments/contracts/testnet.json b/forge-contracts/deployments/contracts/testnet.json index ba3e456bf..a36ef8cd7 100644 --- a/forge-contracts/deployments/contracts/testnet.json +++ b/forge-contracts/deployments/contracts/testnet.json @@ -20,9 +20,9 @@ "bytes": "ATb8qnA5iu712mcGbR0p/8DOS/OUecq03SoLnK7hE9pIAgAAAAABAQAAAQABKfF8GetZuFkfQSAQso2cXYUWAPfGnYvnVDSRvYDVCXABBwNlbmMWBBIEdHlwZRIFYXJyYXkSCWJ5dGVBcnJheRMBEghtaW5JdGVtcwIdEghtYXhJdGVtcwL7FAADaDMyFgISBHR5cGUSBWJ5dGVzEgRzaXplAiACaWQWARIEdHlwZRIKaWRlbnRpZmllcgNudW0WAxIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIBEgdtYXhpbXVtAvz/////A29pZBYEEgR0eXBlEgVhcnJheRIJYnl0ZUFycmF5EwESCG1pbkl0ZW1zAhQSCG1heEl0ZW1zAiADdTMyFgMSBHR5cGUSB2ludGVnZXISB21pbmltdW0CABIHbWF4aW11bQL8/////wN2aXMWAhIEdHlwZRIGc3RyaW5nEgRlbnVtFQISBnB1YmxpYxIHcHJpdmF0ZQkLYXV0aG9yRXZlbnQWChIEdHlwZRIGb2JqZWN0EhBkb2N1bWVudHNNdXRhYmxlEwASDGNhbkJlRGVsZXRlZBMAEg1vd25lclJlZmVyc1RvFgESBWFueU9mFQIWBRIEdHlwZRIRcGVybWFuZW50RG9jdW1lbnQSDGRvY3VtZW50VHlwZRIFaXNzdWUSBmZpbmRCeRYDEggkb3duZXJJZBIBLhIGcmVwb0lkEgZyZXBvSWQSBm51bWJlchIMdGFyZ2V0TnVtYmVyEgV3aGVyZRYBEgMkaWQSCHRhcmdldElkEgpjb250cmFjdElkEixDNWIzSHlzM1piMjhkZnJoRHpuM3ROZFFETkNQVTJaSllna3NkZ0RKZTd2ZRYFEgR0eXBlEhFwZXJtYW5lbnREb2N1bWVudBIMZG9jdW1lbnRUeXBlEgVwYXRjaBIGZmluZEJ5FgMSCCRvd25lcklkEgEuEgZyZXBvSWQSBnJlcG9JZBIGbnVtYmVyEgx0YXJnZXROdW1iZXISBXdoZXJlFgESAyRpZBIIdGFyZ2V0SWQSCmNvbnRyYWN0SWQSLEM1YjNIeXMzWmIyOGRmcmhEem4zdE5kUUROQ1BVMlpKWWdrc2RnREplN3ZlEgpwcm9wZXJ0aWVzFgoSBnJlcG9JZBYCEgQkcmVmEgojLyRkZWZzL2lkEghwb3NpdGlvbgIAEgh0YXJnZXRJZBYDEgR0eXBlEgppZGVudGlmaWVyEghyZWZlcnNUbxYBEgVhbnlPZhUCFgQSBHR5cGUSEXBlcm1hbmVudERvY3VtZW50Egxkb2N1bWVudFR5cGUSBWlzc3VlEgV3aGVyZRYDEgZyZXBvSWQSBnJlcG9JZBIGbnVtYmVyEgx0YXJnZXROdW1iZXISA2F1ZBIEdEF1ZBIKY29udHJhY3RJZBIsQzViM0h5czNaYjI4ZGZyaER6bjN0TmRRRE5DUFUyWkpZZ2tzZGdESmU3dmUWBBIEdHlwZRIRcGVybWFuZW50RG9jdW1lbnQSDGRvY3VtZW50VHlwZRIFcGF0Y2gSBXdoZXJlFgMSBnJlcG9JZBIGcmVwb0lkEgZudW1iZXISDHRhcmdldE51bWJlchIDYXVkEgR0QXVkEgpjb250cmFjdElkEixDNWIzSHlzM1piMjhkZnJoRHpuM3ROZFFETkNQVTJaSllna3NkZ0RKZTd2ZRIIcG9zaXRpb24CARIMdGFyZ2V0TnVtYmVyFgISBCRyZWYSCyMvJGRlZnMvbnVtEghwb3NpdGlvbgICEgRraW5kFgUSBHR5cGUSB2ludGVnZXISB21pbmltdW0CARIHbWF4aW11bQL7AP8SBGVudW0VBgILAgwCDQIOAhACCBIIcG9zaXRpb24CAxIFcmVmSWQWAhIEdHlwZRIKaWRlbnRpZmllchIIcG9zaXRpb24CBBIDb2lkFgISBCRyZWYSCyMvJGRlZnMvb2lkEghwb3NpdGlvbgIFEgV2YWx1ZRYFEgR0eXBlEgZzdHJpbmcSCW1pbkxlbmd0aAIBEgltYXhMZW5ndGgCeBIIbWF4Qnl0ZXMC+wHgEghwb3NpdGlvbgIGEgR0QXVkFgQSBHR5cGUSB2ludGVnZXISB21pbmltdW0CARIHbWF4aW11bQICEghwb3NpdGlvbgIHEgNlbmMWAhIEJHJlZhILIy8kZGVmcy9lbmMSCHBvc2l0aW9uAggSBWVwb2NoFgISBCRyZWYSCyMvJGRlZnMvdTMyEghwb3NpdGlvbgIJEgdpbmRpY2VzFQMWAhIEbmFtZRIGdGFyZ2V0Egpwcm9wZXJ0aWVzFQIWARIIdGFyZ2V0SWQSA2FzYxYBEgokY3JlYXRlZEF0EgNhc2MWAhIEbmFtZRIEZmVlZBIKcHJvcGVydGllcxUCFgESBnJlcG9JZBIDYXNjFgESCiRjcmVhdGVkQXQSA2FzYxYDEgRuYW1lEglhZGRyZXNzZWUSCnByb3BlcnRpZXMVAhYBEgVyZWZJZBIDYXNjFgESCiRjcmVhdGVkQXQSA2FzYxIMc2tpcElmQWJzZW50FQESBXJlZklkEghyZXF1aXJlZBUFEgokY3JlYXRlZEF0EgZyZXBvSWQSCHRhcmdldElkEgx0YXJnZXROdW1iZXISBGtpbmQSFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwASE3Byb3BlcnR5Q29uc3RyYWludHMWBhIJbmVlZFJlZklkFgESBWFueU9mFQIWARIDbm90FgESAmluFQISBGtpbmQVBAILAgwCDQIOFgESB3ByZXNlbnQSBXJlZklkEgduZWVkT2lkFgESBWFueU9mFQIWARIIbm90RXF1YWwVAhIEa2luZAIQFgESB3ByZXNlbnQSA29pZBIIb2lkV2lkdGgWARICaW4VAhYBEgVjb3VudBIDb2lkFQMCAAIUAiASDXJldGFyZ2V0VmFsdWUWARIKaWZUaGVuRWxzZRUDFgESBWVxdWFsFQISBGtpbmQCCBYBEgVhbnlPZhUCFgESB3ByZXNlbnQSBXZhbHVlFgESB3ByZXNlbnQSA2VuYxYBEgZhYnNlbnQSBXZhbHVlEgp0QXVkU2VhbGVkFgESBWFueU9mFQIWARIGYWJzZW50EgR0QXVkFgESBmFic2VudBIFdmFsdWUSB25vUGxhaW4WARIFYW55T2YVAhYBEgZhYnNlbnQSA2VuYxYBEgZhYnNlbnQSBXZhbHVlEhFkZXBlbmRlbnRSZXF1aXJlZBYBEgNlbmMVARIFZXBvY2gIY2hlY2tSdW4WChIEdHlwZRIGb2JqZWN0EglpbW11dGFibGUVDhIGcmVwb0lkEgdoZWFkT2lkEgRuYW1lEgN2aXMSA2F1ZBYCEghwcm9wZXJ0eRIJc3RhcnRlZEF0EgR3aGVuFgESB3ByZXNlbnQSDiRvbGQuc3RhcnRlZEF0FgISCHByb3BlcnR5Egtjb21wbGV0ZWRBdBIEd2hlbhYBEgdwcmVzZW50EhAkb2xkLmNvbXBsZXRlZEF0FgISCHByb3BlcnR5Egpjb25jbHVzaW9uEgR3aGVuFgESB3ByZXNlbnQSDyRvbGQuY29uY2x1c2lvbhYCEghwcm9wZXJ0eRIKZXh0ZXJuYWxJZBIEd2hlbhYBEgdwcmVzZW50Eg8kb2xkLmV4dGVybmFsSWQWAhIIcHJvcGVydHkSB3N1bW1hcnkSBHdoZW4WARIFZXF1YWwVAhILJG9sZC5zdGF0dXMWARIFY29uc3QSCWNvbXBsZXRlZBYCEghwcm9wZXJ0eRIKZGV0YWlsc1VybBIEd2hlbhYBEgVlcXVhbBUCEgskb2xkLnN0YXR1cxYBEgVjb25zdBIJY29tcGxldGVkFgISCHByb3BlcnR5EgZsb2dVcmwSBHdoZW4WARIFZXF1YWwVAhILJG9sZC5zdGF0dXMWARIFY29uc3QSCWNvbXBsZXRlZBYCEghwcm9wZXJ0eRIJbG9nU2hhMjU2EgR3aGVuFgESBWVxdWFsFQISCyRvbGQuc3RhdHVzFgESBWNvbnN0Egljb21wbGV0ZWQWAhIIcHJvcGVydHkSCWFydGlmYWN0cxIEd2hlbhYBEgVlcXVhbBUCEgskb2xkLnN0YXR1cxYBEgVjb25zdBIJY29tcGxldGVkEg1vd25lclJlZmVyc1RvFgESBWFueU9mFQMWAxIEdHlwZRIRZGVsZXRhYmxlRG9jdW1lbnQSDGRvY3VtZW50VHlwZRIGcnVubmVyEgZmaW5kQnkWAhIGcmVwb0lkEgZyZXBvSWQSCG1lbWJlcklkEgEuFgQSBHR5cGUSEWRlbGV0YWJsZURvY3VtZW50Egpjb250cmFjdElkEixEMlpMZGdnaFpUS0dwRVMzNWEzS1ZEcDVuZWNTZlpxcVJITFNrbmpSUEFWORIMZG9jdW1lbnRUeXBlEgptYWludGFpbmVyEgZmaW5kQnkWAhIGcmVwb0lkEgZyZXBvSWQSCG1lbWJlcklkEgEuFgUSBHR5cGUSEWRlbGV0YWJsZURvY3VtZW50Egpjb250cmFjdElkEixEMlpMZGdnaFpUS0dwRVMzNWEzS1ZEcDVuZWNTZlpxcVJITFNrbmpSUEFWORIMZG9jdW1lbnRUeXBlEgZ3cml0ZXISBmZpbmRCeRYCEgZyZXBvSWQSBnJlcG9JZBIIbWVtYmVySWQSAS4SBXdoZXJlFgESBHJvbGUSAXISCnByb3BlcnRpZXMWERIGcmVwb0lkFgMSBHR5cGUSCmlkZW50aWZpZXISCHJlZmVyc1RvFgQSBHR5cGUSEXBlcm1hbmVudERvY3VtZW50Egpjb250cmFjdElkEixEMlpMZGdnaFpUS0dwRVMzNWEzS1ZEcDVuZWNTZlpxcVJITFNrbmpSUEFWORIMZG9jdW1lbnRUeXBlEgRyZXBvEgV3aGVyZRYBEgp2aXNpYmlsaXR5EgN2aXMSCHBvc2l0aW9uAgASB2hlYWRPaWQWAhIEJHJlZhILIy8kZGVmcy9vaWQSCHBvc2l0aW9uAgESBG5hbWUWBRIEdHlwZRIGc3RyaW5nEgltaW5MZW5ndGgCARIJbWF4TGVuZ3RoAmQSCG1heEJ5dGVzAsgSCHBvc2l0aW9uAgISBnN0YXR1cxYDEgR0eXBlEgZzdHJpbmcSBGVudW0VAxIGcXVldWVkEgtpbl9wcm9ncmVzcxIJY29tcGxldGVkEghwb3NpdGlvbgIDEgpjb25jbHVzaW9uFgMSBHR5cGUSBnN0cmluZxIEZW51bRUIEgdzdWNjZXNzEgdmYWlsdXJlEgduZXV0cmFsEgljYW5jZWxsZWQSB3NraXBwZWQSCXRpbWVkX291dBIPYWN0aW9uX3JlcXVpcmVkEgVzdGFsZRIIcG9zaXRpb24CBBIKZGV0YWlsc1VybBYGEgR0eXBlEgZzdHJpbmcSCW1heExlbmd0aAL7ASwSCG1heEJ5dGVzAvsBLBIJbWluTGVuZ3RoAgESCHBvc2l0aW9uAgUSB3BhdHRlcm4SMF5odHRwczovL1teWzpzcGFjZTpdLz8jQF0rKFsvPyNdW15bOnNwYWNlOl1dKik/JBIHc3VtbWFyeRYFEgR0eXBlEgZzdHJpbmcSCW1heExlbmd0aAL7A+gSCG1heEJ5dGVzAvsH0BIJbWluTGVuZ3RoAgESCHBvc2l0aW9uAgYSCmV4dGVybmFsSWQWBRIEdHlwZRIGc3RyaW5nEgltaW5MZW5ndGgCARIJbWF4TGVuZ3RoAngSCG1heEJ5dGVzAngSCHBvc2l0aW9uAgcSCXN0YXJ0ZWRBdBYDEgR0eXBlEgdpbnRlZ2VyEgdtaW5pbXVtAgASCHBvc2l0aW9uAggSC2NvbXBsZXRlZEF0FgMSBHR5cGUSB2ludGVnZXISB21pbmltdW0CABIIcG9zaXRpb24CCRIJYXJ0aWZhY3RzFgUSBHR5cGUSBnN0cmluZxIJbWluTGVuZ3RoAgESCW1heExlbmd0aAL7EAASCG1heEJ5dGVzAvsQABIIcG9zaXRpb24CChIGbG9nVXJsFgYSBHR5cGUSBnN0cmluZxIJbWluTGVuZ3RoAgESCW1heExlbmd0aAL7ASwSCG1heEJ5dGVzAvsBLBIIcG9zaXRpb24CCxIHcGF0dGVybhJGXihodHRwczovL1teWzpzcGFjZTpdLz8jQF0rfGlwZnM6Ly9bQS1aYS16MC05XSspKFsvPyNdW15bOnNwYWNlOl1dKik/JBIJbG9nU2hhMjU2FgMSBHR5cGUSBWJ5dGVzEgRzaXplAiASCHBvc2l0aW9uAgwSB291dGNvbWUWBBIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIAEgdtYXhpbXVtAgISCHBvc2l0aW9uAg0SA3ZpcxYCEgQkcmVmEgsjLyRkZWZzL3ZpcxIIcG9zaXRpb24CDhIBchYEEgR0eXBlEgdpbnRlZ2VyEgdtaW5pbXVtAgESB21heGltdW0CARIIcG9zaXRpb24CDxIDYXVkFgQSBHR5cGUSB2ludGVnZXISB21pbmltdW0CARIHbWF4aW11bQIBEghwb3NpdGlvbgIQEgdpbmRpY2VzFQQWAhIEbmFtZRIEaGVhZBIKcHJvcGVydGllcxUDFgESBnJlcG9JZBIDYXNjFgESB2hlYWRPaWQSA2FzYxYBEgokY3JlYXRlZEF0EgNhc2MWAhIEbmFtZRIGcmVjZW50Egpwcm9wZXJ0aWVzFQIWARIGcmVwb0lkEgNhc2MWARIKJGNyZWF0ZWRBdBIDYXNjFgISBG5hbWUSB3VwZGF0ZWQSCnByb3BlcnRpZXMVAhYBEgZyZXBvSWQSA2FzYxYBEgokdXBkYXRlZEF0EgNhc2MWAxIEbmFtZRIHb3V0Y29tZRIKcHJvcGVydGllcxUDFgESBnJlcG9JZBIDYXNjFgESB2hlYWRPaWQSA2FzYxYBEgdvdXRjb21lEgNhc2MSDnJhbmdlQ291bnRhYmxlEwESCHJlcXVpcmVkFQkSCiRjcmVhdGVkQXQSCiR1cGRhdGVkQXQSBnJlcG9JZBIHaGVhZE9pZBIEbmFtZRIGc3RhdHVzEgdvdXRjb21lEgN2aXMSAXISFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwASEWRlcGVuZGVudFJlcXVpcmVkFgISBmxvZ1VybBUBEglsb2dTaGEyNTYSCWxvZ1NoYTI1NhUBEgZsb2dVcmwSE3Byb3BlcnR5Q29uc3RyYWludHMWDRIQY29uY2x1c2lvbklmRG9uZRYBEgVhbnlPZhUCFgESCG5vdEVxdWFsFQISBnN0YXR1cxYBEgVjb25zdBIJY29tcGxldGVkFgESB3ByZXNlbnQSCmNvbmNsdXNpb24SEGRvbmVJZkNvbmNsdXNpb24WARIFYW55T2YVAhYBEgVlcXVhbBUCEgZzdGF0dXMWARIFY29uc3QSCWNvbXBsZXRlZBYBEgZhYnNlbnQSCmNvbmNsdXNpb24SEHN0YXJ0ZWRJZlJ1bm5pbmcWARIFYW55T2YVAhYBEgVlcXVhbBUCEgZzdGF0dXMWARIFY29uc3QSBnF1ZXVlZBYBEgdwcmVzZW50EglzdGFydGVkQXQSEHJ1bm5pbmdJZlN0YXJ0ZWQWARIFYW55T2YVAhYBEgZhYnNlbnQSCXN0YXJ0ZWRBdBYBEghub3RFcXVhbBUCEgZzdGF0dXMWARIFY29uc3QSBnF1ZXVlZBIRY29tcGxldGVkQXRJZkRvbmUWARIFYW55T2YVAhYBEghub3RFcXVhbBUCEgZzdGF0dXMWARIFY29uc3QSCWNvbXBsZXRlZBYBEgdwcmVzZW50Egtjb21wbGV0ZWRBdBIRZG9uZUlmQ29tcGxldGVkQXQWARIFYW55T2YVAhYBEgZhYnNlbnQSC2NvbXBsZXRlZEF0FgESBWVxdWFsFQISBnN0YXR1cxYBEgVjb25zdBIJY29tcGxldGVkEg5kb25lQWZ0ZXJTdGFydBYBEgVhbnlPZhUCFgESBmFic2VudBILY29tcGxldGVkQXQWARISZ3JlYXRlclRoYW5PckVxdWFsFQISC2NvbXBsZXRlZEF0EglzdGFydGVkQXQSB21zRXBvY2gWARIFYW55T2YVAhYBEgZhYnNlbnQSCXN0YXJ0ZWRBdBYBEhJncmVhdGVyVGhhbk9yRXF1YWwVAhIJc3RhcnRlZEF0Av0AAADo1KUQABIJbm90RnV0dXJlFgESD2xlc3NUaGFuT3JFcXVhbBUCFgESA21heBUCFgESCGlmQWJzZW50FQISCXN0YXJ0ZWRBdAIAFgESCGlmQWJzZW50FQISC2NvbXBsZXRlZEF0AgAWARIDYWRkFQISCiR1cGRhdGVkQXQC/AA27oASCG9pZFdpZHRoFgESAmluFQIWARIFY291bnQSB2hlYWRPaWQVAgIUAiASCW91dGNvbWVPZhYBEgppZlRoZW5FbHNlFQMWARIIbm90RXF1YWwVAhIGc3RhdHVzFgESBWNvbnN0Egljb21wbGV0ZWQWARIFZXF1YWwVAhIHb3V0Y29tZQIAFgESCmlmVGhlbkVsc2UVAxYBEgJpbhUCEgpjb25jbHVzaW9uFQMSB3N1Y2Nlc3MSB25ldXRyYWwSB3NraXBwZWQWARIFZXF1YWwVAhIHb3V0Y29tZQIBFgESBWVxdWFsFQISB291dGNvbWUCAhIMc2VhbGVkTm9UZXh0FgESBWFueU9mFQIWARIFYWxsT2YVAhYBEghub3RFcXVhbBUCEgN2aXMWARIFY29uc3QSB3ByaXZhdGUWARIGYWJzZW50EgNhdWQWARIFYWxsT2YVBBYBEgZhYnNlbnQSB3N1bW1hcnkWARIGYWJzZW50EgpkZXRhaWxzVXJsFgESBmFic2VudBIJYXJ0aWZhY3RzFgESBmFic2VudBIKZXh0ZXJuYWxJZBIGckNsYWltFgESBWVxdWFsFQISAXICARIRZGVsZXRlQ29uc3RyYWludHMWARINa2VlcENvbXBsZXRlZBYBEghub3RFcXVhbBUCEgZzdGF0dXMWARIFY29uc3QSCWNvbXBsZXRlZAVldmVudBYKEgR0eXBlEgZvYmplY3QSEGRvY3VtZW50c011dGFibGUTABIMY2FuQmVEZWxldGVkEwASEWRlcGVuZGVudFJlcXVpcmVkFgESA2VuYxUBEgVlcG9jaBINb3duZXJSZWZlcnNUbxYBEgVhbnlPZhUCFgQSBHR5cGUSEWRlbGV0YWJsZURvY3VtZW50Egpjb250cmFjdElkEixEMlpMZGdnaFpUS0dwRVMzNWEzS1ZEcDVuZWNTZlpxcVJITFNrbmpSUEFWORIMZG9jdW1lbnRUeXBlEgptYWludGFpbmVyEgZmaW5kQnkWAhIGcmVwb0lkEgZyZXBvSWQSCG1lbWJlcklkEgEuFgUSBHR5cGUSEWRlbGV0YWJsZURvY3VtZW50Egpjb250cmFjdElkEixEMlpMZGdnaFpUS0dwRVMzNWEzS1ZEcDVuZWNTZlpxcVJITFNrbmpSUEFWORIMZG9jdW1lbnRUeXBlEgZ3cml0ZXISBmZpbmRCeRYCEgZyZXBvSWQSBnJlcG9JZBIIbWVtYmVySWQSAS4SBXdoZXJlFgESBHJvbGUSAXISCnByb3BlcnRpZXMWDBIGcmVwb0lkFgISBCRyZWYSCiMvJGRlZnMvaWQSCHBvc2l0aW9uAgASCHRhcmdldElkFgMSBHR5cGUSCmlkZW50aWZpZXISCHJlZmVyc1RvFgESBWFueU9mFQIWBBIEdHlwZRIRcGVybWFuZW50RG9jdW1lbnQSDGRvY3VtZW50VHlwZRIFaXNzdWUSBXdoZXJlFgMSBnJlcG9JZBIGcmVwb0lkEgZudW1iZXISDHRhcmdldE51bWJlchIDYXVkEgR0QXVkEgpjb250cmFjdElkEixDNWIzSHlzM1piMjhkZnJoRHpuM3ROZFFETkNQVTJaSllna3NkZ0RKZTd2ZRYEEgR0eXBlEhFwZXJtYW5lbnREb2N1bWVudBIMZG9jdW1lbnRUeXBlEgVwYXRjaBIFd2hlcmUWAxIGcmVwb0lkEgZyZXBvSWQSBm51bWJlchIMdGFyZ2V0TnVtYmVyEgNhdWQSBHRBdWQSCmNvbnRyYWN0SWQSLEM1YjNIeXMzWmIyOGRmcmhEem4zdE5kUUROQ1BVMlpKWWdrc2RnREplN3ZlEghwb3NpdGlvbgIBEgx0YXJnZXROdW1iZXIWAhIEJHJlZhILIy8kZGVmcy9udW0SCHBvc2l0aW9uAgISBGtpbmQWBBIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIEEgdtYXhpbXVtAvsA/xIIcG9zaXRpb24CAxIFdmFsdWUWBRIEdHlwZRIGc3RyaW5nEgltYXhMZW5ndGgCeBIIbWF4Qnl0ZXMC+wHgEgltaW5MZW5ndGgCARIIcG9zaXRpb24CBBIDb2lkFgISBCRyZWYSCyMvJGRlZnMvb2lkEghwb3NpdGlvbgIFEgVyZWZJZBYCEgR0eXBlEgppZGVudGlmaWVyEghwb3NpdGlvbgIGEgNlbmMWAhIEJHJlZhILIy8kZGVmcy9lbmMSCHBvc2l0aW9uAgcSBWVwb2NoFgISBCRyZWYSCyMvJGRlZnMvdTMyEghwb3NpdGlvbgIIEgxhc01haW50YWluZXIWAxIEdHlwZRIKaWRlbnRpZmllchIIcmVmZXJzVG8WBBIEdHlwZRIRZGVsZXRhYmxlRG9jdW1lbnQSCmNvbnRyYWN0SWQSLEQyWkxkZ2doWlRLR3BFUzM1YTNLVkRwNW5lY1NmWnFxUkhMU2tualJQQVY5Egxkb2N1bWVudFR5cGUSCm1haW50YWluZXISBmZpbmRCeRYCEgZyZXBvSWQSBnJlcG9JZBIIbWVtYmVySWQSAS4SCHBvc2l0aW9uAgkSAXIWBBIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIBEgdtYXhpbXVtAgISCHBvc2l0aW9uAgoSBHRBdWQWBBIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIBEgdtYXhpbXVtAgISCHBvc2l0aW9uAgsSB2luZGljZXMVBBYCEgRuYW1lEgZ0YXJnZXQSCnByb3BlcnRpZXMVAhYBEgh0YXJnZXRJZBIDYXNjFgESCiRjcmVhdGVkQXQSA2FzYxYCEgRuYW1lEgRmZWVkEgpwcm9wZXJ0aWVzFQIWARIGcmVwb0lkEgNhc2MWARIKJGNyZWF0ZWRBdBIDYXNjFgMSBG5hbWUSCWFkZHJlc3NlZRIKcHJvcGVydGllcxUCFgESBXJlZklkEgNhc2MWARIKJGNyZWF0ZWRBdBIDYXNjEgxza2lwSWZBYnNlbnQVARIFcmVmSWQWAhIEbmFtZRIGYnlLaW5kEgpwcm9wZXJ0aWVzFQIWARIGcmVwb0lkEgNhc2MWARIEa2luZBIDYXNjEghyZXF1aXJlZBUGEgokY3JlYXRlZEF0EgZyZXBvSWQSCHRhcmdldElkEgx0YXJnZXROdW1iZXISBGtpbmQSAXISFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwASE3Byb3BlcnR5Q29uc3RyYWludHMWCxIHbm9QbGFpbhYBEgVhbnlPZhUCFgESBmFic2VudBIDZW5jFgESBmFic2VudBIFdmFsdWUSCW5lZWRWYWx1ZRYBEgVhbnlPZhUDFgESA25vdBYBEgJpbhUCEgRraW5kFQQCBAIFAggCERYBEgdwcmVzZW50EgV2YWx1ZRYBEgdwcmVzZW50EgNlbmMSDG5lZWRBc3NpZ25lZRYBEgVhbnlPZhUCFgESA25vdBYBEgJpbhUCEgRraW5kFQICBgIHFgESBWFsbE9mFQIWARIHcHJlc2VudBIFcmVmSWQWARIFYW55T2YVAhYBEgdwcmVzZW50EgV2YWx1ZRYBEgdwcmVzZW50EgNlbmMSCW5lZWRSZWZJZBYBEgVhbnlPZhUCFgESA25vdBYBEgJpbhUCEgRraW5kFQUCCwIMAg0CDgIPFgESB3ByZXNlbnQSBXJlZklkEgduZWVkT2lkFgESBWFueU9mFQIWARIIbm90RXF1YWwVAhIEa2luZAIQFgESB3ByZXNlbnQSA29pZBIHbm9TdGF0ZRYBEgVub3RJbhUCEgRraW5kFQQCCQIKAhUCFhIIb2lkV2lkdGgWARICaW4VAhYBEgVjb3VudBIDb2lkFQMCAAIUAiASC2hpZGVCeU1haW50FgESBmlmVGhlbhUCFgESAmluFQISBGtpbmQVAwIXAhgCGRYBEgVlcXVhbBUCEgxhc01haW50YWluZXISCCRvd25lcklkEg10X3RyaWFnZUtpbmRzFgESBmlmVGhlbhUCFgESBWVxdWFsFQISAXICAhYBEgJpbhUCEgRraW5kFQoCBAIFAgYCBwILAgwCDQIOAhECEhIKdEF1ZFNlYWxlZBYBEgVhbnlPZhUCFgESBmFic2VudBIEdEF1ZBYBEgZhYnNlbnQSBXZhbHVlEgZyQ2xhaW0WARICaW4VAhIBchUCAgECAgltaWxlc3RvbmUWChIEdHlwZRIGb2JqZWN0EhBkb2N1bWVudHNNdXRhYmxlEwASDGNhbkJlRGVsZXRlZBMBEg1vd25lclJlZmVyc1RvFgESBWFueU9mFQIWBBIEdHlwZRIRZGVsZXRhYmxlRG9jdW1lbnQSCmNvbnRyYWN0SWQSLEQyWkxkZ2doWlRLR3BFUzM1YTNLVkRwNW5lY1NmWnFxUkhMU2tualJQQVY5Egxkb2N1bWVudFR5cGUSCm1haW50YWluZXISBmZpbmRCeRYCEgZyZXBvSWQSBnJlcG9JZBIIbWVtYmVySWQSAS4WBRIEdHlwZRIRZGVsZXRhYmxlRG9jdW1lbnQSCmNvbnRyYWN0SWQSLEQyWkxkZ2doWlRLR3BFUzM1YTNLVkRwNW5lY1NmWnFxUkhMU2tualJQQVY5Egxkb2N1bWVudFR5cGUSBndyaXRlchIGZmluZEJ5FgISBnJlcG9JZBIGcmVwb0lkEghtZW1iZXJJZBIBLhIFd2hlcmUWARIEcm9sZRIBchIRZGVwZW5kZW50UmVxdWlyZWQWARIDZW5jFQESBWVwb2NoEgpwcm9wZXJ0aWVzFggSBnJlcG9JZBYCEgQkcmVmEgojLyRkZWZzL2lkEghwb3NpdGlvbgIAEgV0aXRsZRYFEgR0eXBlEgZzdHJpbmcSCW1pbkxlbmd0aAIBEgltYXhMZW5ndGgCPxIIbWF4Qnl0ZXMC+wD8Eghwb3NpdGlvbgIBEgtkZXNjcmlwdGlvbhYFEgR0eXBlEgZzdHJpbmcSCW1pbkxlbmd0aAIBEgltYXhMZW5ndGgC+wPoEghtYXhCeXRlcwL7B9ASCHBvc2l0aW9uAgISBWR1ZU9uFgMSBHR5cGUSB2ludGVnZXISB21pbmltdW0CABIIcG9zaXRpb24CAxIGY2xvc2VkFgISBHR5cGUSB2Jvb2xlYW4SCHBvc2l0aW9uAgQSA2VuYxYCEgQkcmVmEgsjLyRkZWZzL2VuYxIIcG9zaXRpb24CBRIFZXBvY2gWAhIEJHJlZhILIy8kZGVmcy91MzISCHBvc2l0aW9uAgYSAXIWBBIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIBEgdtYXhpbXVtAgISCHBvc2l0aW9uAgcSB2luZGljZXMVARYCEgRuYW1lEgZieVJlcG8SCnByb3BlcnRpZXMVAxYBEgZyZXBvSWQSA2FzYxYBEgV0aXRsZRIDYXNjFgESCiRjcmVhdGVkQXQSA2FzYxITcHJvcGVydHlDb25zdHJhaW50cxYCEgdub1BsYWluFgESBWFueU9mFQIWARIGYWJzZW50EgNlbmMWARIFYWxsT2YVAhYBEgZhYnNlbnQSC2Rlc2NyaXB0aW9uFgESBmFic2VudBIFZHVlT24SBnJDbGFpbRYBEgJpbhUCEgFyFQICAQICEghyZXF1aXJlZBUEEgokY3JlYXRlZEF0EgZyZXBvSWQSBXRpdGxlEgFyEhRhZGRpdGlvbmFsUHJvcGVydGllcxMABnBvbGljeRYJEgR0eXBlEgZvYmplY3QSEGRvY3VtZW50c011dGFibGUTABIMY2FuQmVEZWxldGVkEwASDW93bmVyUmVmZXJzVG8WBBIEdHlwZRIRZGVsZXRhYmxlRG9jdW1lbnQSCmNvbnRyYWN0SWQSLEQyWkxkZ2doWlRLR3BFUzM1YTNLVkRwNW5lY1NmWnFxUkhMU2tualJQQVY5Egxkb2N1bWVudFR5cGUSCm1haW50YWluZXISBmZpbmRCeRYCEgZyZXBvSWQSBnJlcG9JZBIIbWVtYmVySWQSAS4SCnByb3BlcnRpZXMWCBIGcmVwb0lkFgISBCRyZWYSCiMvJGRlZnMvaWQSCHBvc2l0aW9uAgASEXJlcXVpcmVkQXBwcm92YWxzFgQSBHR5cGUSB2ludGVnZXISB21pbmltdW0CABIHbWF4aW11bQIKEghwb3NpdGlvbgIBEgxhcHByb3ZlclJvbGUWBBIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIAEgdtYXhpbXVtAgESCHBvc2l0aW9uAgISDXJlcXVpcmVDaGVja3MWAhIEdHlwZRIHYm9vbGVhbhIIcG9zaXRpb24CAxIMbWVyZ2VNZXRob2RzFgQSBHR5cGUSB2ludGVnZXISB21pbmltdW0CABIHbWF4aW11bQIPEghwb3NpdGlvbgIEEg5yZXF1aXJlZENoZWNrcxYFEgR0eXBlEgVhcnJheRIIbWF4SXRlbXMCChILdW5pcXVlSXRlbXMTARIFaXRlbXMWBBIEdHlwZRIGc3RyaW5nEgltaW5MZW5ndGgCARIJbWF4TGVuZ3RoAmQSCG1heEJ5dGVzAsgSCHBvc2l0aW9uAgUSFHJlcXVpcmVkQ2hlY2tTb3VyY2VzFgQSBHR5cGUSBWFycmF5EghtYXhJdGVtcwIKEgVpdGVtcxYCEgR0eXBlEgppZGVudGlmaWVyEghyZWZlcnNUbxYBEgVhbnlPZhUCFgMSBHR5cGUSEWRlbGV0YWJsZURvY3VtZW50Egxkb2N1bWVudFR5cGUSBnJ1bm5lchIGZmluZEJ5FgISBnJlcG9JZBIGcmVwb0lkEghtZW1iZXJJZBIBLhYEEgR0eXBlEhFkZWxldGFibGVEb2N1bWVudBIKY29udHJhY3RJZBIsRDJaTGRnZ2haVEtHcEVTMzVhM0tWRHA1bmVjU2ZacXFSSExTa25qUlBBVjkSDGRvY3VtZW50VHlwZRIKbWFpbnRhaW5lchIGZmluZEJ5FgISBnJlcG9JZBIGcmVwb0lkEghtZW1iZXJJZBIBLhIIcG9zaXRpb24CBhIRcmVxdWlyZUNvZGVPd25lcnMWAhIEdHlwZRIHYm9vbGVhbhIIcG9zaXRpb24CBxIHaW5kaWNlcxUBFgISBG5hbWUSB2NyZWF0ZWQSCnByb3BlcnRpZXMVAhYBEgZyZXBvSWQSA2FzYxYBEgokY3JlYXRlZEF0EgNhc2MSCHJlcXVpcmVkFQMSCiRjcmVhdGVkQXQSBnJlcG9JZBIRcmVxdWlyZWRBcHByb3ZhbHMSFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwASE3Byb3BlcnR5Q29uc3RyYWludHMWARIRc291cmNlc01hdGNoTmFtZXMWARIFYW55T2YVAhYBEgVlcXVhbBUCFgESBWNvdW50EhRyZXF1aXJlZENoZWNrU291cmNlcwIAFgESBWVxdWFsFQIWARIFY291bnQSFHJlcXVpcmVkQ2hlY2tTb3VyY2VzFgESBWNvdW50Eg5yZXF1aXJlZENoZWNrcwZydW5uZXIWBxIEdHlwZRIGb2JqZWN0EhBkb2N1bWVudHNNdXRhYmxlEwASDGNhbkJlRGVsZXRlZBMBEgpwcm9wZXJ0aWVzFgISBnJlcG9JZBYDEgR0eXBlEgppZGVudGlmaWVyEghyZWZlcnNUbxYEEgR0eXBlEhFwZXJtYW5lbnREb2N1bWVudBIMZG9jdW1lbnRUeXBlEgRyZXBvEgV3aGVyZRYBEggkb3duZXJJZBIIJG93bmVySWQSCmNvbnRyYWN0SWQSLEQyWkxkZ2doWlRLR3BFUzM1YTNLVkRwNW5lY1NmWnFxUkhMU2tualJQQVY5Eghwb3NpdGlvbgIAEghtZW1iZXJJZBYDEgR0eXBlEgppZGVudGlmaWVyEghyZWZlcnNUbxYBEgR0eXBlEghpZGVudGl0eRIIcG9zaXRpb24CARIHaW5kaWNlcxUCFgMSBG5hbWUSDGJ5UmVwb01lbWJlchIKcHJvcGVydGllcxUCFgESBnJlcG9JZBIDYXNjFgESCG1lbWJlcklkEgNhc2MSBnVuaXF1ZRMBFgISBG5hbWUSCGJ5TWVtYmVyEgpwcm9wZXJ0aWVzFQEWARIIbWVtYmVySWQSA2FzYxIIcmVxdWlyZWQVAxIKJGNyZWF0ZWRBdBIGcmVwb0lkEghtZW1iZXJJZBIUYWRkaXRpb25hbFByb3BlcnRpZXMTAARzdGFyFgcSBHR5cGUSBm9iamVjdBIQZG9jdW1lbnRzTXV0YWJsZRMAEglpbmRleE9ubHkTARIKcHJvcGVydGllcxYBEgZyZXBvSWQWAxIEdHlwZRIKaWRlbnRpZmllchIIcmVmZXJzVG8WBBIEdHlwZRIRcGVybWFuZW50RG9jdW1lbnQSCmNvbnRyYWN0SWQSLEQyWkxkZ2doWlRLR3BFUzM1YTNLVkRwNW5lY1NmWnFxUkhMU2tualJQQVY5Egxkb2N1bWVudFR5cGUSBHJlcG8SBXdoZXJlFgESCnZpc2liaWxpdHkWARIFY29uc3QSBnB1YmxpYxIIcG9zaXRpb24CABIHaW5kaWNlcxUDFgQSBG5hbWUSBmJ5UmVwbxIKcHJvcGVydGllcxUBFgESBnJlcG9JZBIDYXNjEg5yYW5nZUNvdW50YWJsZRMBEg9yYW5rZWRDb3VudGFibGUTARYEEgRuYW1lEgdieU93bmVyEgpwcm9wZXJ0aWVzFQEWARIIJG93bmVySWQSA2FzYxIIdGVybWluYWwSBnJlcG9JZBIJY291bnRhYmxlEwEWBhIEbmFtZRIGYnlXZWVrEgpwcm9wZXJ0aWVzFQIWARIKJGNyZWF0ZWRBdBIDYXNjFgESBnJlcG9JZBIDYXNjEgl0aW1lUmFuZ2UWBBICb24SCiRjcmVhdGVkQXQSBXJhbmdlAvwACTqAEgRzdGVwAvwAAVGAEgN0dGwC/AAJOoASDnJhbmdlQ291bnRhYmxlEwESD3JhbmtlZENvdW50YWJsZRMBEg5vdXRsaXZlc0RlbGV0ZRMBEghyZXF1aXJlZBUCEgZyZXBvSWQSCiRjcmVhdGVkQXQSFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwAFd2F0Y2gWBxIEdHlwZRIGb2JqZWN0EhBkb2N1bWVudHNNdXRhYmxlEwASCWluZGV4T25seRMBEgpwcm9wZXJ0aWVzFgESBnJlcG9JZBYDEgR0eXBlEgppZGVudGlmaWVyEghyZWZlcnNUbxYEEgR0eXBlEhFwZXJtYW5lbnREb2N1bWVudBIKY29udHJhY3RJZBIsRDJaTGRnZ2haVEtHcEVTMzVhM0tWRHA1bmVjU2ZacXFSSExTa25qUlBBVjkSDGRvY3VtZW50VHlwZRIEcmVwbxIFd2hlcmUWARIKdmlzaWJpbGl0eRYBEgVjb25zdBIGcHVibGljEghwb3NpdGlvbgIAEgdpbmRpY2VzFQIWBBIEbmFtZRIGYnlSZXBvEgpwcm9wZXJ0aWVzFQEWARIGcmVwb0lkEgNhc2MSDnJhbmdlQ291bnRhYmxlEwESD3JhbmtlZENvdW50YWJsZRMBFgQSBG5hbWUSB2J5T3duZXISCnByb3BlcnRpZXMVARYBEggkb3duZXJJZBIDYXNjEgh0ZXJtaW5hbBIGcmVwb0lkEgljb3VudGFibGUTARIIcmVxdWlyZWQVARIGcmVwb0lkEhRhZGRpdGlvbmFsUHJvcGVydGllcxMAB3dlYmhvb2sWBxIEdHlwZRIGb2JqZWN0EglpbW11dGFibGUVAhIGcmVwb0lkEgZob29rSWQSDW93bmVyUmVmZXJzVG8WBBIEdHlwZRIRZGVsZXRhYmxlRG9jdW1lbnQSCmNvbnRyYWN0SWQSLEQyWkxkZ2doWlRLR3BFUzM1YTNLVkRwNW5lY1NmWnFxUkhMU2tualJQQVY5Egxkb2N1bWVudFR5cGUSCm1haW50YWluZXISBmZpbmRCeRYCEgZyZXBvSWQSBnJlcG9JZBIIbWVtYmVySWQSAS4SCnByb3BlcnRpZXMWCRIGcmVwb0lkFgMSBHR5cGUSCmlkZW50aWZpZXISCHJlZmVyc1RvFgQSBHR5cGUSEXBlcm1hbmVudERvY3VtZW50Egpjb250cmFjdElkEixEMlpMZGdnaFpUS0dwRVMzNWEzS1ZEcDVuZWNTZlpxcVJITFNrbmpSUEFWORIMZG9jdW1lbnRUeXBlEgRyZXBvEgV3aGVyZRYBEgp2aXNpYmlsaXR5FgESBWNvbnN0EgZwdWJsaWMSCHBvc2l0aW9uAgASBmhvb2tJZBYCEgQkcmVmEgsjLyRkZWZzL2gzMhIIcG9zaXRpb24CARIDdXJsFgYSBHR5cGUSBnN0cmluZxIJbWluTGVuZ3RoAgESCW1heExlbmd0aAL7ASwSCG1heEJ5dGVzAvsBLBIIcG9zaXRpb24CAhIHcGF0dGVybhJgXmh0dHBzOi8vKFtBLVphLXowLTktXStbLl0pK1tBLVphLXpdW0EtWmEtejAtOS1dKltBLVphLXowLTldKDpbMC05XXsxLDV9KT8oWy8/I11bXls6c3BhY2U6XV0qKT8kEgZldmVudHMWBRIEdHlwZRIFYXJyYXkSCG1heEl0ZW1zAhASC3VuaXF1ZUl0ZW1zEwESBWl0ZW1zFgMSBHR5cGUSBnN0cmluZxIJbWluTGVuZ3RoAgESCW1heExlbmd0aAIeEghwb3NpdGlvbgIDEg9yZWxheUlkZW50aXR5SWQWAxIEdHlwZRIKaWRlbnRpZmllchIIcmVmZXJzVG8WAxIEdHlwZRIRaWRlbnRpdHlQdWJsaWNLZXkSDWtleUlkUHJvcGVydHkSCnJlbGF5S2V5SWQSD2tleVJlcXVpcmVtZW50cxYBEgdwdXJwb3NlEgplbmNyeXB0aW9uEghwb3NpdGlvbgIEEgpyZWxheUtleUlkFgQSBHR5cGUSB2ludGVnZXISB21pbmltdW0CABIHbWF4aW11bQL8/////xIIcG9zaXRpb24CBRILc2VuZGVyS2V5SWQWBRIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIAEgdtYXhpbXVtAvz/////EghyZWZlcnNUbxYDEgR0eXBlEhFpZGVudGl0eVB1YmxpY0tleRIQaWRlbnRpdHlQcm9wZXJ0eRIIJG93bmVySWQSD2tleVJlcXVpcmVtZW50cxYBEgdwdXJwb3NlEgplbmNyeXB0aW9uEghwb3NpdGlvbgIGEgZzZWNyZXQWBhIEdHlwZRIFYXJyYXkSCWJ5dGVBcnJheRMBEghtaW5JdGVtcwIgEghtYXhJdGVtcwKAEgxlbmNyeXB0ZWRGb3IWBBIJcmVjaXBpZW50Eg9yZWxheUlkZW50aXR5SWQSDHJlY2lwaWVudEtleRIKcmVsYXlLZXlJZBIJc2VuZGVyS2V5EgtzZW5kZXJLZXlJZBIGc2NoZW1lEhllY2RoLXNlY3AyNTZrMS1hZXMyNTYtY2JjEghwb3NpdGlvbgIHEghkaXNhYmxlZBYCEgR0eXBlEgdib29sZWFuEghwb3NpdGlvbgIIEgdpbmRpY2VzFQMWAhIEbmFtZRIEaG9vaxIKcHJvcGVydGllcxUDFgESBnJlcG9JZBIDYXNjFgESBmhvb2tJZBIDYXNjFgESCiRjcmVhdGVkQXQSA2FzYxYCEgRuYW1lEgRsaXN0Egpwcm9wZXJ0aWVzFQIWARIGcmVwb0lkEgNhc2MWARIKJGNyZWF0ZWRBdBIDYXNjFgISBG5hbWUSBXJlbGF5Egpwcm9wZXJ0aWVzFQIWARIPcmVsYXlJZGVudGl0eUlkEgNhc2MWARIKJGNyZWF0ZWRBdBIDYXNjEghyZXF1aXJlZBUIEgokY3JlYXRlZEF0EgZyZXBvSWQSBmhvb2tJZBIDdXJsEg9yZWxheUlkZW50aXR5SWQSCnJlbGF5S2V5SWQSC3NlbmRlcktleUlkEgZzZWNyZXQSFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwAB/QAAAaF27gTDAAH8AAnbGgAB+028AAAAAAFbRGFzaCBGb3JnZSB2MiBjb21tdW5pdHk6IGV2ZW50cywgbWlsZXN0b25lcywgcnVubmVycywgY2hlY2sgcnVucywgcG9saWNpZXMsIHN0YXJzLCB3ZWJob29rcw==" }, "6arQJW8yxf7ZfqrwJU92CtzD5JoG51uWw6koR9Haqw93": { - "version": 2, + "version": 3, "platformVersion": 14, - "bytes": "AVL2dcdbooEM3k0N7KUuQfTBxpiY5BHadVhszAsdPOX6AgAAAAABAQAAAQACKfF8GetZuFkfQSAQso2cXYUWAPfGnYvnVDSRvYDVCXABBANlbmMWBBIEdHlwZRIFYXJyYXkSCWJ5dGVBcnJheRMBEghtaW5JdGVtcwIdEghtYXhJdGVtcwL7BgADaGlkFgESBHR5cGUSCmlkZW50aWZpZXICaWQWARIEdHlwZRIKaWRlbnRpZmllcgN1MzIWAxIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIAEgdtYXhpbXVtAvz/////CANiYW4WCBIEdHlwZRIGb2JqZWN0EhBkb2N1bWVudHNNdXRhYmxlEwASDGNhbkJlRGVsZXRlZBMBEg1vd25lclJlZmVyc1RvFgQSBHR5cGUSEWRlbGV0YWJsZURvY3VtZW50Egpjb250cmFjdElkEixEMlpMZGdnaFpUS0dwRVMzNWEzS1ZEcDVuZWNTZlpxcVJITFNrbmpSUEFWORIMZG9jdW1lbnRUeXBlEgptYWludGFpbmVyEgZmaW5kQnkWAhIGcmVwb0lkEgZyZXBvSWQSCG1lbWJlcklkEgEuEgpwcm9wZXJ0aWVzFgMSBnJlcG9JZBYCEgR0eXBlEgppZGVudGlmaWVyEghwb3NpdGlvbgIAEgppZGVudGl0eUlkFgISBHR5cGUSCmlkZW50aWZpZXISCHBvc2l0aW9uAgESBnJlYXNvbhYEEgR0eXBlEgdpbnRlZ2VyEgdtaW5pbXVtAgASB21heGltdW0C+wD/Eghwb3NpdGlvbgICEgdpbmRpY2VzFQEWAxIEbmFtZRIGYnlSZXBvEgpwcm9wZXJ0aWVzFQMWARIGcmVwb0lkEgNhc2MWARIKaWRlbnRpdHlJZBIDYXNjFgESCCRvd25lcklkEgNhc2MSBnVuaXF1ZRMBEghyZXF1aXJlZBUDEgokY3JlYXRlZEF0EgZyZXBvSWQSCmlkZW50aXR5SWQSFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwAGZm9sbG93FgcSBHR5cGUSBm9iamVjdBIQZG9jdW1lbnRzTXV0YWJsZRMAEglpbmRleE9ubHkTARIKcHJvcGVydGllcxYBEgppZGVudGl0eUlkFgQSBHR5cGUSCmlkZW50aWZpZXISDGRpc3RpbmN0RnJvbRIIJG93bmVySWQSCHJlZmVyc1RvFgESBHR5cGUSCGlkZW50aXR5Eghwb3NpdGlvbgIAEgdpbmRpY2VzFQIWBBIEbmFtZRIIYnlUYXJnZXQSCnByb3BlcnRpZXMVARYBEgppZGVudGl0eUlkEgNhc2MSDnJhbmdlQ291bnRhYmxlEwESD3JhbmtlZENvdW50YWJsZRMBFgQSBG5hbWUSB2J5T3duZXISCnByb3BlcnRpZXMVARYBEggkb3duZXJJZBIDYXNjEgh0ZXJtaW5hbBIKaWRlbnRpdHlJZBIJY291bnRhYmxlEgljb3VudGFibGUSCHJlcXVpcmVkFQESCmlkZW50aXR5SWQSFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwAFbGFiZWwWChIEdHlwZRIGb2JqZWN0EhBkb2N1bWVudHNNdXRhYmxlEwASDGNhbkJlRGVsZXRlZBMBEg1vd25lclJlZmVyc1RvFgESBWFueU9mFQIWBBIEdHlwZRIRZGVsZXRhYmxlRG9jdW1lbnQSDGRvY3VtZW50VHlwZRIKbWFpbnRhaW5lchIGZmluZEJ5FgISBnJlcG9JZBIGcmVwb0lkEghtZW1iZXJJZBIBLhIKY29udHJhY3RJZBIsRDJaTGRnZ2haVEtHcEVTMzVhM0tWRHA1bmVjU2ZacXFSSExTa25qUlBBVjkWBRIEdHlwZRIRZGVsZXRhYmxlRG9jdW1lbnQSDGRvY3VtZW50VHlwZRIGd3JpdGVyEgZmaW5kQnkWAhIGcmVwb0lkEgZyZXBvSWQSCG1lbWJlcklkEgEuEgV3aGVyZRYBEgRyb2xlEgFyEgpjb250cmFjdElkEixEMlpMZGdnaFpUS0dwRVMzNWEzS1ZEcDVuZWNTZlpxcVJITFNrbmpSUEFWORIKcHJvcGVydGllcxYIEgZyZXBvSWQWAhIEJHJlZhIKIy8kZGVmcy9pZBIIcG9zaXRpb24CABIEbmFtZRYGEgR0eXBlEgZzdHJpbmcSCW1pbkxlbmd0aAIBEgltYXhMZW5ndGgCHhIIbWF4Qnl0ZXMCPBIIcG9zaXRpb24CARIHcGF0dGVybhI6XlteXHNceDAwLVx4MWZceDdmXShbXlx4MDAtXHgxZlx4N2ZdKlteXHNceDAwLVx4MWZceDdmXSk/JBIFY29sb3IWBBIEdHlwZRIGc3RyaW5nEgltYXhMZW5ndGgCBxIHcGF0dGVybhIRXiNbMC05YS1mQS1GXXs2fSQSCHBvc2l0aW9uAgISC2Rlc2NyaXB0aW9uFgQSBHR5cGUSBnN0cmluZxIJbWF4TGVuZ3RoAsgSCG1heEJ5dGVzAvsBkBIIcG9zaXRpb24CAxIHcmV0aXJlZBYCEgR0eXBlEgdib29sZWFuEghwb3NpdGlvbgIEEgNlbmMWAhIEJHJlZhILIy8kZGVmcy9lbmMSCHBvc2l0aW9uAgUSBWVwb2NoFgQSBHR5cGUSB2ludGVnZXISB21pbmltdW0CABIHbWF4aW11bQL8/////xIIcG9zaXRpb24CBhIBchYEEgR0eXBlEgdpbnRlZ2VyEgdtaW5pbXVtAgESB21heGltdW0CAhIIcG9zaXRpb24CBxIHaW5kaWNlcxUBFgISBG5hbWUSBG5hbWUSCnByb3BlcnRpZXMVAxYBEgZyZXBvSWQSA2FzYxYBEgRuYW1lEgNhc2MWARIKJGNyZWF0ZWRBdBIDYXNjEghyZXF1aXJlZBUEEgokY3JlYXRlZEF0EgZyZXBvSWQSBG5hbWUSAXISFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwASEWRlcGVuZGVudFJlcXVpcmVkFgESA2VuYxUBEgVlcG9jaBITcHJvcGVydHlDb25zdHJhaW50cxYCEgdub1BsYWluFgESBWFueU9mFQIWARIGYWJzZW50EgNlbmMWARIFYWxsT2YVAhYBEgZhYnNlbnQSBWNvbG9yFgESBmFic2VudBILZGVzY3JpcHRpb24SBnJDbGFpbRYBEgJpbhUCEgFyFQICAQICCnBhY2tNaXJyb3IWBxIEdHlwZRIGb2JqZWN0EhBkb2N1bWVudHNNdXRhYmxlEwASDGNhbkJlRGVsZXRlZBMBEgpwcm9wZXJ0aWVzFgQSBnJlcG9JZBYDEgR0eXBlEgppZGVudGlmaWVyEghyZWZlcnNUbxYEEgR0eXBlEhFwZXJtYW5lbnREb2N1bWVudBIMZG9jdW1lbnRUeXBlEgRyZXBvEgV3aGVyZRYBEgp2aXNpYmlsaXR5FgESBWNvbnN0EgZwdWJsaWMSCmNvbnRyYWN0SWQSLEQyWkxkZ2doWlRLR3BFUzM1YTNLVkRwNW5lY1NmWnFxUkhMU2tualJQQVY5Eghwb3NpdGlvbgIAEghwYWNrSGFzaBYCEgQkcmVmEgsjLyRkZWZzL2hpZBIIcG9zaXRpb24CARIEa2luZBYEEgR0eXBlEgdpbnRlZ2VyEgdtaW5pbXVtAgESB21heGltdW0C+wD/Eghwb3NpdGlvbgICEgR1cmlzFgUSBHR5cGUSBWFycmF5EghtaW5JdGVtcwIBEghtYXhJdGVtcwIEEgVpdGVtcxYEEgR0eXBlEgZzdHJpbmcSCW1pbkxlbmd0aAIBEgltYXhMZW5ndGgC+wEsEgdwYXR0ZXJuEkZeKGh0dHBzOi8vW15bOnNwYWNlOl0vPyNAXSt8aXBmczovL1tBLVphLXowLTldKykoWy8/I11bXls6c3BhY2U6XV0qKT8kEghwb3NpdGlvbgIDEgdpbmRpY2VzFQIWAxIEbmFtZRIGYnlIYXNoEgpwcm9wZXJ0aWVzFQMWARIGcmVwb0lkEgNhc2MWARIIcGFja0hhc2gSA2FzYxYBEggkb3duZXJJZBIDYXNjEgZ1bmlxdWUTARYCEgRuYW1lEgdieU93bmVyEgpwcm9wZXJ0aWVzFQIWARIIJG93bmVySWQSA2FzYxYBEgokY3JlYXRlZEF0EgNhc2MSCHJlcXVpcmVkFQUSCiRjcmVhdGVkQXQSBnJlcG9JZBIIcGFja0hhc2gSBGtpbmQSBHVyaXMSFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwAHcHJvZmlsZRYEEgR0eXBlEgZvYmplY3QSCnByb3BlcnRpZXMWCRILZGlzcGxheU5hbWUWBBIEdHlwZRIGc3RyaW5nEgltYXhMZW5ndGgCPBIIbWF4Qnl0ZXMC8BIIcG9zaXRpb24CABIDYmlvFgQSBHR5cGUSBnN0cmluZxIJbWF4TGVuZ3RoAvsB9BIIbWF4Qnl0ZXMC+wPoEghwb3NpdGlvbgIBEgxhdmF0YXJDb25maWcWBBIEdHlwZRIGc3RyaW5nEgltYXhMZW5ndGgCyBIIbWF4Qnl0ZXMCyBIIcG9zaXRpb24CAhIFbGlua3MWBBIEdHlwZRIFYXJyYXkSCG1heEl0ZW1zAgQSBWl0ZW1zFgQSBHR5cGUSBnN0cmluZxIJbWluTGVuZ3RoAgESCW1heExlbmd0aALIEgdwYXR0ZXJuEjBeaHR0cHM6Ly9bXls6c3BhY2U6XS8/I0BdKyhbLz8jXVteWzpzcGFjZTpdXSopPyQSCHBvc2l0aW9uAgMSCGxvY2F0aW9uFgUSBHR5cGUSBnN0cmluZxIJbWluTGVuZ3RoAgESCW1heExlbmd0aAI8EghtYXhCeXRlcwLwEghwb3NpdGlvbgIEEgdjb21wYW55FgUSBHR5cGUSBnN0cmluZxIJbWluTGVuZ3RoAgESCW1heExlbmd0aAI8EghtYXhCeXRlcwLwEghwb3NpdGlvbgIFEgdwdWJrZXlzFgUSBHR5cGUSBWFycmF5EghtYXhJdGVtcwIEEgt1bmlxdWVJdGVtcxMBEgVpdGVtcxYEEgR0eXBlEgZzdHJpbmcSCW1pbkxlbmd0aAIBEgltYXhMZW5ndGgC+wEsEghtYXhCeXRlcwL7ASwSCHBvc2l0aW9uAgYSCWtleVByb29mcxYEEgR0eXBlEgVhcnJheRIIbWF4SXRlbXMCBBIFaXRlbXMWBBIEdHlwZRIGc3RyaW5nEgltaW5MZW5ndGgCABIJbWF4TGVuZ3RoAvsEsBIHcGF0dGVybhIWXltBLVphLXowLTkrL10qPXswLDJ9JBIIcG9zaXRpb24CBxIDYm90FgQSBHR5cGUSBm9iamVjdBIKcHJvcGVydGllcxYCEghvcGVyYXRvchYCEgR0eXBlEgppZGVudGlmaWVyEghwb3NpdGlvbgIAEghvcGVyYXRlcxYEEgR0eXBlEgVhcnJheRIIbWF4SXRlbXMCCBIFaXRlbXMWARIEdHlwZRIKaWRlbnRpZmllchIIcG9zaXRpb24CARIUYWRkaXRpb25hbFByb3BlcnRpZXMTABIIcG9zaXRpb24CCBIHaW5kaWNlcxUBFgMSBG5hbWUSBW93bmVyEgpwcm9wZXJ0aWVzFQEWARIIJG93bmVySWQSA2FzYxIGdW5pcXVlEwESFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwAHcmVwb0tleRYJEgR0eXBlEgZvYmplY3QSEGRvY3VtZW50c011dGFibGUTABIMY2FuQmVEZWxldGVkEwASDW93bmVyUmVmZXJzVG8WBBIEdHlwZRIRZGVsZXRhYmxlRG9jdW1lbnQSDGRvY3VtZW50VHlwZRIKbWFpbnRhaW5lchIGZmluZEJ5FgISBnJlcG9JZBIGcmVwb0lkEghtZW1iZXJJZBIBLhIKY29udHJhY3RJZBIsRDJaTGRnZ2haVEtHcEVTMzVhM0tWRHA1bmVjU2ZacXFSSExTa25qUlBBVjkSCnByb3BlcnRpZXMWBxIGcmVwb0lkFgISBCRyZWYSCiMvJGRlZnMvaWQSCHBvc2l0aW9uAgASCG1lbWJlcklkFgMSBHR5cGUSCmlkZW50aWZpZXISCHJlZmVyc1RvFgESBWFueU9mFQIWBBIEdHlwZRIRZGVsZXRhYmxlRG9jdW1lbnQSCmNvbnRyYWN0SWQSLEQyWkxkZ2doWlRLR3BFUzM1YTNLVkRwNW5lY1NmWnFxUkhMU2tualJQQVY5Egxkb2N1bWVudFR5cGUSCm1haW50YWluZXISBmZpbmRCeRYCEgZyZXBvSWQSBnJlcG9JZBIIbWVtYmVySWQSAS4WBRIEdHlwZRIRZGVsZXRhYmxlRG9jdW1lbnQSCmNvbnRyYWN0SWQSLEQyWkxkZ2doWlRLR3BFUzM1YTNLVkRwNW5lY1NmWnFxUkhMU2tualJQQVY5Egxkb2N1bWVudFR5cGUSBndyaXRlchIGZmluZEJ5FgISBnJlcG9JZBIGcmVwb0lkEghtZW1iZXJJZBIBLhIFd2hlcmUWARIEcm9sZRICbXISCHBvc2l0aW9uAgESBWVwb2NoFgISBCRyZWYSCyMvJGRlZnMvdTMyEghwb3NpdGlvbgICEg5yZWNpcGllbnRLZXlJZBYFEgR0eXBlEgdpbnRlZ2VyEgdtaW5pbXVtAgASB21heGltdW0C/P////8SCHBvc2l0aW9uAgMSCHJlZmVyc1RvFgMSBHR5cGUSEWlkZW50aXR5UHVibGljS2V5EhBpZGVudGl0eVByb3BlcnR5EghtZW1iZXJJZBIPa2V5UmVxdWlyZW1lbnRzFgESB3B1cnBvc2USCmVuY3J5cHRpb24SC3NlbmRlcktleUlkFgUSBHR5cGUSB2ludGVnZXISB21pbmltdW0CABIHbWF4aW11bQL8/////xIIcmVmZXJzVG8WAxIEdHlwZRIRaWRlbnRpdHlQdWJsaWNLZXkSEGlkZW50aXR5UHJvcGVydHkSCCRvd25lcklkEg9rZXlSZXF1aXJlbWVudHMWARIHcHVycG9zZRIKZW5jcnlwdGlvbhIIcG9zaXRpb24CBBIHd3JhcHBlZBYGEgR0eXBlEgVhcnJheRIJYnl0ZUFycmF5EwESCG1pbkl0ZW1zAiASCG1heEl0ZW1zAmASDGVuY3J5cHRlZEZvchYEEglyZWNpcGllbnQSCG1lbWJlcklkEgxyZWNpcGllbnRLZXkSDnJlY2lwaWVudEtleUlkEglzZW5kZXJLZXkSC3NlbmRlcktleUlkEgZzY2hlbWUSGWVjZGgtc2VjcDI1NmsxLWFlczI1Ni1jYmMSCHBvc2l0aW9uAgUSAm1yFgQSBHR5cGUSB2ludGVnZXISB21pbmltdW0CARIHbWF4aW11bQIDEghwb3NpdGlvbgIGEgdpbmRpY2VzFQIWAxIEbmFtZRILbWVtYmVyRXBvY2gSCnByb3BlcnRpZXMVBBYBEgZyZXBvSWQSA2FzYxYBEghtZW1iZXJJZBIDYXNjFgESBWVwb2NoEgNhc2MWARIIJG93bmVySWQSA2FzYxIGdW5pcXVlEwEWAhIEbmFtZRIIYnlNZW1iZXISCnByb3BlcnRpZXMVARYBEghtZW1iZXJJZBIDYXNjEghyZXF1aXJlZBUJEgokY3JlYXRlZEF0EhUkY3JlYXRlZEF0QmxvY2tIZWlnaHQSBnJlcG9JZBIIbWVtYmVySWQSBWVwb2NoEg5yZWNpcGllbnRLZXlJZBILc2VuZGVyS2V5SWQSB3dyYXBwZWQSAm1yEhRhZGRpdGlvbmFsUHJvcGVydGllcxMAEhNwcm9wZXJ0eUNvbnN0cmFpbnRzFgESB21yQ2xhaW0WARICaW4VAhICbXIVAwIBAgICAwV0b3BpYxYIEgR0eXBlEgZvYmplY3QSEGRvY3VtZW50c011dGFibGUTABIMY2FuQmVEZWxldGVkEwESCnByb3BlcnRpZXMWAhIGcmVwb0lkFgMSBHR5cGUSCmlkZW50aWZpZXISCHJlZmVyc1RvFgQSBHR5cGUSEXBlcm1hbmVudERvY3VtZW50Egxkb2N1bWVudFR5cGUSBHJlcG8SBXdoZXJlFgISCCRvd25lcklkEggkb3duZXJJZBIKdmlzaWJpbGl0eRYBEgVjb25zdBIGcHVibGljEgpjb250cmFjdElkEixEMlpMZGdnaFpUS0dwRVMzNWEzS1ZEcDVuZWNTZlpxcVJITFNrbmpSUEFWORIIcG9zaXRpb24CABIEbmFtZRYGEgR0eXBlEgZzdHJpbmcSCW1pbkxlbmd0aAIBEgltYXhMZW5ndGgCHhIIbWF4Qnl0ZXMCHhIHcGF0dGVybhIYXlthLXowLTldKygtW2EtejAtOV0rKSokEghwb3NpdGlvbgIBEgdpbmRpY2VzFQMWAxIEbmFtZRIGYnlSZXBvEgpwcm9wZXJ0aWVzFQIWARIGcmVwb0lkEgNhc2MWARIEbmFtZRIDYXNjEgZ1bmlxdWUTARYEEgRuYW1lEgZieU5hbWUSCnByb3BlcnRpZXMVAhYBEgRuYW1lEgNhc2MWARIKJGNyZWF0ZWRBdBIDYXNjEg5yYW5nZUNvdW50YWJsZRMBEg9yYW5rZWRDb3VudGFibGUWARICYXQSBG5hbWUWAxIEbmFtZRIHcGVyUmVwbxIKcHJvcGVydGllcxUBFgESBnJlcG9JZBIDYXNjEgljb3VudGFibGUTARIIcmVxdWlyZWQVAxIKJGNyZWF0ZWRBdBIGcmVwb0lkEgRuYW1lEhRhZGRpdGlvbmFsUHJvcGVydGllcxMAEhNwcm9wZXJ0eUNvbnN0cmFpbnRzFgESCGF0TW9zdDIwFgESD2xlc3NUaGFuT3JFcXVhbBUCFgESB2NvdW50T2YVAhIFdG9waWMWARIGcmVwb0lkEgZyZXBvSWQCFAp2YXVsdEVudHJ5FggSBHR5cGUSBm9iamVjdBIQZG9jdW1lbnRzTXV0YWJsZRMBEgxjYW5CZURlbGV0ZWQTARIKcHJvcGVydGllcxYGEgxjcmVkZW50aWFsSWQWBRIEdHlwZRIFYXJyYXkSCWJ5dGVBcnJheRMBEghtaW5JdGVtcwIQEghtYXhJdGVtcwL7AP8SCHBvc2l0aW9uAgASDHJlY2lwaWVudEtleRYDEgR0eXBlEgVieXRlcxIEc2l6ZQIgEghwb3NpdGlvbgIBEgd2ZXJzaW9uFgQSBHR5cGUSB2ludGVnZXISB21pbmltdW0CARIHbWF4aW11bQL7AP8SCHBvc2l0aW9uAgISCWF1dGhLZXlJZBYFEgR0eXBlEgdpbnRlZ2VyEgdtaW5pbXVtAgASB21heGltdW0C/P////8SCHBvc2l0aW9uAgMSCHJlZmVyc1RvFgMSBHR5cGUSEWlkZW50aXR5UHVibGljS2V5EhBpZGVudGl0eVByb3BlcnR5Eggkb3duZXJJZBIPa2V5UmVxdWlyZW1lbnRzFgESB3B1cnBvc2USDmF1dGhlbnRpY2F0aW9uEgNlbmMWAxIEdHlwZRIFYnl0ZXMSBHNpemUCIBIIcG9zaXRpb24CBBIGc2VhbGVkFgUSBHR5cGUSBWFycmF5EglieXRlQXJyYXkTARIIbWluSXRlbXMCIBIIbWF4SXRlbXMC+wEAEghwb3NpdGlvbgIFEglpbW11dGFibGUVAhIMY3JlZGVudGlhbElkEgxyZWNpcGllbnRLZXkSB2luZGljZXMVARYDEgRuYW1lEgxieUNyZWRlbnRpYWwSCnByb3BlcnRpZXMVAhYBEggkb3duZXJJZBIDYXNjFgESDGNyZWRlbnRpYWxJZBIDYXNjEgZ1bmlxdWUTARIIcmVxdWlyZWQVCBIKJGNyZWF0ZWRBdBIKJHVwZGF0ZWRBdBIMY3JlZGVudGlhbElkEgxyZWNpcGllbnRLZXkSB3ZlcnNpb24SCWF1dGhLZXlJZBIDZW5jEgZzZWFsZWQSFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwAB/QAAAaF27g/wAf0AAAGheWtwjgH8AAnbHAH8AAniWAH7TbwB+03IAAAAAVREYXNoIEZvcmdlIHYyIG1ldGE6IHJlcG8ga2V5cywgYmFucywgbGFiZWxzLCB0b3BpY3MsIHBhY2sgbWlycm9ycywgcHJvZmlsZXMsIGZvbGxvd3M=" + "bytes": "AVL2dcdbooEM3k0N7KUuQfTBxpiY5BHadVhszAsdPOX6AgAAAAABAQAAAQADKfF8GetZuFkfQSAQso2cXYUWAPfGnYvnVDSRvYDVCXABBANlbmMWBBIEdHlwZRIFYXJyYXkSCWJ5dGVBcnJheRMBEghtaW5JdGVtcwIdEghtYXhJdGVtcwL7BgADaGlkFgESBHR5cGUSCmlkZW50aWZpZXICaWQWARIEdHlwZRIKaWRlbnRpZmllcgN1MzIWAxIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIAEgdtYXhpbXVtAvz/////CgNiYW4WCBIEdHlwZRIGb2JqZWN0EhBkb2N1bWVudHNNdXRhYmxlEwASDGNhbkJlRGVsZXRlZBMBEg1vd25lclJlZmVyc1RvFgQSBHR5cGUSEWRlbGV0YWJsZURvY3VtZW50Egpjb250cmFjdElkEixEMlpMZGdnaFpUS0dwRVMzNWEzS1ZEcDVuZWNTZlpxcVJITFNrbmpSUEFWORIMZG9jdW1lbnRUeXBlEgptYWludGFpbmVyEgZmaW5kQnkWAhIGcmVwb0lkEgZyZXBvSWQSCG1lbWJlcklkEgEuEgpwcm9wZXJ0aWVzFgMSBnJlcG9JZBYCEgR0eXBlEgppZGVudGlmaWVyEghwb3NpdGlvbgIAEgppZGVudGl0eUlkFgISBHR5cGUSCmlkZW50aWZpZXISCHBvc2l0aW9uAgESBnJlYXNvbhYEEgR0eXBlEgdpbnRlZ2VyEgdtaW5pbXVtAgASB21heGltdW0C+wD/Eghwb3NpdGlvbgICEgdpbmRpY2VzFQEWAxIEbmFtZRIGYnlSZXBvEgpwcm9wZXJ0aWVzFQMWARIGcmVwb0lkEgNhc2MWARIKaWRlbnRpdHlJZBIDYXNjFgESCCRvd25lcklkEgNhc2MSBnVuaXF1ZRMBEghyZXF1aXJlZBUDEgokY3JlYXRlZEF0EgZyZXBvSWQSCmlkZW50aXR5SWQSFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwAFYm9hcmQWCxIEdHlwZRIGb2JqZWN0EhBkb2N1bWVudHNNdXRhYmxlEwESDGNhbkJlRGVsZXRlZBMAEg1vd25lclJlZmVyc1RvFgESBWFueU9mFQIWBBIEdHlwZRIRZGVsZXRhYmxlRG9jdW1lbnQSCmNvbnRyYWN0SWQSLEQyWkxkZ2doWlRLR3BFUzM1YTNLVkRwNW5lY1NmWnFxUkhMU2tualJQQVY5Egxkb2N1bWVudFR5cGUSCm1haW50YWluZXISBmZpbmRCeRYCEgZyZXBvSWQSBnJlcG9JZBIIbWVtYmVySWQSAS4WBRIEdHlwZRIRZGVsZXRhYmxlRG9jdW1lbnQSCmNvbnRyYWN0SWQSLEQyWkxkZ2doWlRLR3BFUzM1YTNLVkRwNW5lY1NmWnFxUkhMU2tualJQQVY5Egxkb2N1bWVudFR5cGUSBndyaXRlchIGZmluZEJ5FgISBnJlcG9JZBIGcmVwb0lkEghtZW1iZXJJZBIBLhIFd2hlcmUWARIEcm9sZRIBchIKcHJvcGVydGllcxYIEgZyZXBvSWQWAhIEJHJlZhIKIy8kZGVmcy9pZBIIcG9zaXRpb24CABIDa2V5FgQSBHR5cGUSB2ludGVnZXISB21pbmltdW0CARIHbWF4aW11bQL8/////xIIcG9zaXRpb24CARIEbmFtZRYGEgR0eXBlEgZzdHJpbmcSCW1pbkxlbmd0aAIBEgltYXhMZW5ndGgCPxIIbWF4Qnl0ZXMC+wD8EgdwYXR0ZXJuEjZeW15ceDAwLVx4MWZceDdmXSpbXlxzXHgwMC1ceDFmXHg3Zl1bXlx4MDAtXHgxZlx4N2ZdKiQSCHBvc2l0aW9uAgISBHNwZWMWBRIEdHlwZRIGc3RyaW5nEgltaW5MZW5ndGgCARIJbWF4TGVuZ3RoAvsQABIIbWF4Qnl0ZXMC+xAAEghwb3NpdGlvbgIDEgVzdGF0ZRYEEgR0eXBlEgdpbnRlZ2VyEgdtaW5pbXVtAgASB21heGltdW0CAhIIcG9zaXRpb24CBBIDZW5jFgUSBHR5cGUSBWFycmF5EglieXRlQXJyYXkTARIIbWluSXRlbXMCHRIIbWF4SXRlbXMC+xQAEghwb3NpdGlvbgIFEgVlcG9jaBYEEgR0eXBlEgdpbnRlZ2VyEgdtaW5pbXVtAgASB21heGltdW0C/P////8SCHBvc2l0aW9uAgYSAXIWBBIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIBEgdtYXhpbXVtAgESCHBvc2l0aW9uAgcSCWltbXV0YWJsZRUCEgZyZXBvSWQSA2tleRIHaW5kaWNlcxUBFgMSBG5hbWUSBWJ5S2V5Egpwcm9wZXJ0aWVzFQMWARIGcmVwb0lkEgNhc2MWARIDa2V5EgNhc2MWARIIJG93bmVySWQSA2FzYxIGdW5pcXVlEwESCHJlcXVpcmVkFQYSCiRjcmVhdGVkQXQSCiR1cGRhdGVkQXQSBnJlcG9JZBIDa2V5EgVzdGF0ZRIBchIUYWRkaXRpb25hbFByb3BlcnRpZXMTABIRZGVwZW5kZW50UmVxdWlyZWQWARIDZW5jFQESBWVwb2NoEhNwcm9wZXJ0eUNvbnN0cmFpbnRzFgMSB25vUGxhaW4WARIFYW55T2YVAhYBEgZhYnNlbnQSA2VuYxYBEgVhbGxPZhUCFgESBmFic2VudBIEbmFtZRYBEgZhYnNlbnQSBHNwZWMSB2hhc05hbWUWARIFYW55T2YVAhYBEgdwcmVzZW50EgNlbmMWARIFYWxsT2YVAhYBEgdwcmVzZW50EgRuYW1lFgESB3ByZXNlbnQSBHNwZWMSBnJDbGFpbRYBEgVlcXVhbBUCEgFyAgEEY2FyZBYLEgR0eXBlEgZvYmplY3QSEGRvY3VtZW50c011dGFibGUTARIMY2FuQmVEZWxldGVkEwASDW93bmVyUmVmZXJzVG8WARIFYW55T2YVAhYEEgR0eXBlEhFkZWxldGFibGVEb2N1bWVudBIKY29udHJhY3RJZBIsRDJaTGRnZ2haVEtHcEVTMzVhM0tWRHA1bmVjU2ZacXFSSExTa25qUlBBVjkSDGRvY3VtZW50VHlwZRIKbWFpbnRhaW5lchIGZmluZEJ5FgISBnJlcG9JZBIGcmVwb0lkEghtZW1iZXJJZBIBLhYFEgR0eXBlEhFkZWxldGFibGVEb2N1bWVudBIKY29udHJhY3RJZBIsRDJaTGRnZ2haVEtHcEVTMzVhM0tWRHA1bmVjU2ZacXFSSExTa25qUlBBVjkSDGRvY3VtZW50VHlwZRIGd3JpdGVyEgZmaW5kQnkWAhIGcmVwb0lkEgZyZXBvSWQSCG1lbWJlcklkEgEuEgV3aGVyZRYBEgRyb2xlEgFyEgpwcm9wZXJ0aWVzFgoSBnJlcG9JZBYCEgQkcmVmEgojLyRkZWZzL2lkEghwb3NpdGlvbgIAEgVib2FyZBYEEgR0eXBlEgdpbnRlZ2VyEgdtaW5pbXVtAgESB21heGltdW0C/P////8SCHBvc2l0aW9uAgESBGl0ZW0WAxIEdHlwZRIKaWRlbnRpZmllchIIcmVmZXJzVG8WARIFYW55T2YVAhYDEgR0eXBlEhFwZXJtYW5lbnREb2N1bWVudBIKY29udHJhY3RJZBIsQzViM0h5czNaYjI4ZGZyaER6bjN0TmRRRE5DUFUyWkpZZ2tzZGdESmU3dmUSDGRvY3VtZW50VHlwZRIFaXNzdWUWAxIEdHlwZRIRcGVybWFuZW50RG9jdW1lbnQSCmNvbnRyYWN0SWQSLEM1YjNIeXMzWmIyOGRmcmhEem4zdE5kUUROQ1BVMlpKWWdrc2RnREplN3ZlEgxkb2N1bWVudFR5cGUSBXBhdGNoEghwb3NpdGlvbgICEgNjb2wWBBIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIAEgdtYXhpbXVtAvsA/xIIcG9zaXRpb24CAxIEcmFuaxYFEgR0eXBlEgZzdHJpbmcSCW1pbkxlbmd0aAIBEgltYXhMZW5ndGgCPxIHcGF0dGVybhIZXlswLTlBLVphLXpdKlsxLTlBLVphLXpdJBIIcG9zaXRpb24CBBIBZhYFEgR0eXBlEgZzdHJpbmcSCW1pbkxlbmd0aAIBEgltYXhMZW5ndGgC+wgAEghtYXhCeXRlcwL7CAASCHBvc2l0aW9uAgUSBXN0YXRlFgQSBHR5cGUSB2ludGVnZXISB21pbmltdW0CABIHbWF4aW11bQICEghwb3NpdGlvbgIGEgNlbmMWBRIEdHlwZRIFYXJyYXkSCWJ5dGVBcnJheRMBEghtaW5JdGVtcwIdEghtYXhJdGVtcwL7CgASCHBvc2l0aW9uAgcSBWVwb2NoFgQSBHR5cGUSB2ludGVnZXISB21pbmltdW0CABIHbWF4aW11bQL8/////xIIcG9zaXRpb24CCBIBchYEEgR0eXBlEgdpbnRlZ2VyEgdtaW5pbXVtAgESB21heGltdW0CAhIIcG9zaXRpb24CCRIJaW1tdXRhYmxlFQMSBnJlcG9JZBIFYm9hcmQSBGl0ZW0SB2luZGljZXMVAhYDEgRuYW1lEgZvbkl0ZW0SCnByb3BlcnRpZXMVBBYBEgRpdGVtEgNhc2MWARIGcmVwb0lkEgNhc2MWARIFYm9hcmQSA2FzYxYBEggkb3duZXJJZBIDYXNjEgZ1bmlxdWUTARYCEgRuYW1lEgZyZWNlbnQSCnByb3BlcnRpZXMVAxYBEgZyZXBvSWQSA2FzYxYBEgVib2FyZBIDYXNjFgESCiR1cGRhdGVkQXQSA2FzYxIIcmVxdWlyZWQVBxIKJGNyZWF0ZWRBdBIKJHVwZGF0ZWRBdBIGcmVwb0lkEgVib2FyZBIEaXRlbRIFc3RhdGUSAXISFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwASEWRlcGVuZGVudFJlcXVpcmVkFgESA2VuYxUBEgVlcG9jaBITcHJvcGVydHlDb25zdHJhaW50cxYCEgdub1BsYWluFgESBWFueU9mFQIWARIGYWJzZW50EgNlbmMWARIFYWxsT2YVAxYBEgZhYnNlbnQSA2NvbBYBEgZhYnNlbnQSBHJhbmsWARIGYWJzZW50EgFmEgZyQ2xhaW0WARICaW4VAhIBchUCAgECAgZmb2xsb3cWBxIEdHlwZRIGb2JqZWN0EhBkb2N1bWVudHNNdXRhYmxlEwASCWluZGV4T25seRMBEgpwcm9wZXJ0aWVzFgESCmlkZW50aXR5SWQWBBIEdHlwZRIKaWRlbnRpZmllchIMZGlzdGluY3RGcm9tEggkb3duZXJJZBIIcmVmZXJzVG8WARIEdHlwZRIIaWRlbnRpdHkSCHBvc2l0aW9uAgASB2luZGljZXMVAhYEEgRuYW1lEghieVRhcmdldBIKcHJvcGVydGllcxUBFgESCmlkZW50aXR5SWQSA2FzYxIOcmFuZ2VDb3VudGFibGUTARIPcmFua2VkQ291bnRhYmxlEwEWBBIEbmFtZRIHYnlPd25lchIKcHJvcGVydGllcxUBFgESCCRvd25lcklkEgNhc2MSCHRlcm1pbmFsEgppZGVudGl0eUlkEgljb3VudGFibGUSCWNvdW50YWJsZRIIcmVxdWlyZWQVARIKaWRlbnRpdHlJZBIUYWRkaXRpb25hbFByb3BlcnRpZXMTAAVsYWJlbBYKEgR0eXBlEgZvYmplY3QSEGRvY3VtZW50c011dGFibGUTABIMY2FuQmVEZWxldGVkEwESDW93bmVyUmVmZXJzVG8WARIFYW55T2YVAhYEEgR0eXBlEhFkZWxldGFibGVEb2N1bWVudBIMZG9jdW1lbnRUeXBlEgptYWludGFpbmVyEgZmaW5kQnkWAhIGcmVwb0lkEgZyZXBvSWQSCG1lbWJlcklkEgEuEgpjb250cmFjdElkEixEMlpMZGdnaFpUS0dwRVMzNWEzS1ZEcDVuZWNTZlpxcVJITFNrbmpSUEFWORYFEgR0eXBlEhFkZWxldGFibGVEb2N1bWVudBIMZG9jdW1lbnRUeXBlEgZ3cml0ZXISBmZpbmRCeRYCEgZyZXBvSWQSBnJlcG9JZBIIbWVtYmVySWQSAS4SBXdoZXJlFgESBHJvbGUSAXISCmNvbnRyYWN0SWQSLEQyWkxkZ2doWlRLR3BFUzM1YTNLVkRwNW5lY1NmWnFxUkhMU2tualJQQVY5Egpwcm9wZXJ0aWVzFggSBnJlcG9JZBYCEgQkcmVmEgojLyRkZWZzL2lkEghwb3NpdGlvbgIAEgRuYW1lFgYSBHR5cGUSBnN0cmluZxIJbWluTGVuZ3RoAgESCW1heExlbmd0aAIeEghtYXhCeXRlcwI8Eghwb3NpdGlvbgIBEgdwYXR0ZXJuEjpeW15cc1x4MDAtXHgxZlx4N2ZdKFteXHgwMC1ceDFmXHg3Zl0qW15cc1x4MDAtXHgxZlx4N2ZdKT8kEgVjb2xvchYEEgR0eXBlEgZzdHJpbmcSCW1heExlbmd0aAIHEgdwYXR0ZXJuEhFeI1swLTlhLWZBLUZdezZ9JBIIcG9zaXRpb24CAhILZGVzY3JpcHRpb24WBBIEdHlwZRIGc3RyaW5nEgltYXhMZW5ndGgCyBIIbWF4Qnl0ZXMC+wGQEghwb3NpdGlvbgIDEgdyZXRpcmVkFgISBHR5cGUSB2Jvb2xlYW4SCHBvc2l0aW9uAgQSA2VuYxYCEgQkcmVmEgsjLyRkZWZzL2VuYxIIcG9zaXRpb24CBRIFZXBvY2gWBBIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIAEgdtYXhpbXVtAvz/////Eghwb3NpdGlvbgIGEgFyFgQSBHR5cGUSB2ludGVnZXISB21pbmltdW0CARIHbWF4aW11bQICEghwb3NpdGlvbgIHEgdpbmRpY2VzFQEWAhIEbmFtZRIEbmFtZRIKcHJvcGVydGllcxUDFgESBnJlcG9JZBIDYXNjFgESBG5hbWUSA2FzYxYBEgokY3JlYXRlZEF0EgNhc2MSCHJlcXVpcmVkFQQSCiRjcmVhdGVkQXQSBnJlcG9JZBIEbmFtZRIBchIUYWRkaXRpb25hbFByb3BlcnRpZXMTABIRZGVwZW5kZW50UmVxdWlyZWQWARIDZW5jFQESBWVwb2NoEhNwcm9wZXJ0eUNvbnN0cmFpbnRzFgISB25vUGxhaW4WARIFYW55T2YVAhYBEgZhYnNlbnQSA2VuYxYBEgVhbGxPZhUCFgESBmFic2VudBIFY29sb3IWARIGYWJzZW50EgtkZXNjcmlwdGlvbhIGckNsYWltFgESAmluFQISAXIVAgIBAgIKcGFja01pcnJvchYHEgR0eXBlEgZvYmplY3QSEGRvY3VtZW50c011dGFibGUTABIMY2FuQmVEZWxldGVkEwESCnByb3BlcnRpZXMWBBIGcmVwb0lkFgMSBHR5cGUSCmlkZW50aWZpZXISCHJlZmVyc1RvFgQSBHR5cGUSEXBlcm1hbmVudERvY3VtZW50Egxkb2N1bWVudFR5cGUSBHJlcG8SBXdoZXJlFgESCnZpc2liaWxpdHkWARIFY29uc3QSBnB1YmxpYxIKY29udHJhY3RJZBIsRDJaTGRnZ2haVEtHcEVTMzVhM0tWRHA1bmVjU2ZacXFSSExTa25qUlBBVjkSCHBvc2l0aW9uAgASCHBhY2tIYXNoFgISBCRyZWYSCyMvJGRlZnMvaGlkEghwb3NpdGlvbgIBEgRraW5kFgQSBHR5cGUSB2ludGVnZXISB21pbmltdW0CARIHbWF4aW11bQL7AP8SCHBvc2l0aW9uAgISBHVyaXMWBRIEdHlwZRIFYXJyYXkSCG1pbkl0ZW1zAgESCG1heEl0ZW1zAgQSBWl0ZW1zFgQSBHR5cGUSBnN0cmluZxIJbWluTGVuZ3RoAgESCW1heExlbmd0aAL7ASwSB3BhdHRlcm4SRl4oaHR0cHM6Ly9bXls6c3BhY2U6XS8/I0BdK3xpcGZzOi8vW0EtWmEtejAtOV0rKShbLz8jXVteWzpzcGFjZTpdXSopPyQSCHBvc2l0aW9uAgMSB2luZGljZXMVAhYDEgRuYW1lEgZieUhhc2gSCnByb3BlcnRpZXMVAxYBEgZyZXBvSWQSA2FzYxYBEghwYWNrSGFzaBIDYXNjFgESCCRvd25lcklkEgNhc2MSBnVuaXF1ZRMBFgISBG5hbWUSB2J5T3duZXISCnByb3BlcnRpZXMVAhYBEggkb3duZXJJZBIDYXNjFgESCiRjcmVhdGVkQXQSA2FzYxIIcmVxdWlyZWQVBRIKJGNyZWF0ZWRBdBIGcmVwb0lkEghwYWNrSGFzaBIEa2luZBIEdXJpcxIUYWRkaXRpb25hbFByb3BlcnRpZXMTAAdwcm9maWxlFgQSBHR5cGUSBm9iamVjdBIKcHJvcGVydGllcxYJEgtkaXNwbGF5TmFtZRYEEgR0eXBlEgZzdHJpbmcSCW1heExlbmd0aAI8EghtYXhCeXRlcwLwEghwb3NpdGlvbgIAEgNiaW8WBBIEdHlwZRIGc3RyaW5nEgltYXhMZW5ndGgC+wH0EghtYXhCeXRlcwL7A+gSCHBvc2l0aW9uAgESDGF2YXRhckNvbmZpZxYEEgR0eXBlEgZzdHJpbmcSCW1heExlbmd0aALIEghtYXhCeXRlcwLIEghwb3NpdGlvbgICEgVsaW5rcxYEEgR0eXBlEgVhcnJheRIIbWF4SXRlbXMCBBIFaXRlbXMWBBIEdHlwZRIGc3RyaW5nEgltaW5MZW5ndGgCARIJbWF4TGVuZ3RoAsgSB3BhdHRlcm4SMF5odHRwczovL1teWzpzcGFjZTpdLz8jQF0rKFsvPyNdW15bOnNwYWNlOl1dKik/JBIIcG9zaXRpb24CAxIIbG9jYXRpb24WBRIEdHlwZRIGc3RyaW5nEgltaW5MZW5ndGgCARIJbWF4TGVuZ3RoAjwSCG1heEJ5dGVzAvASCHBvc2l0aW9uAgQSB2NvbXBhbnkWBRIEdHlwZRIGc3RyaW5nEgltaW5MZW5ndGgCARIJbWF4TGVuZ3RoAjwSCG1heEJ5dGVzAvASCHBvc2l0aW9uAgUSB3B1YmtleXMWBRIEdHlwZRIFYXJyYXkSCG1heEl0ZW1zAgQSC3VuaXF1ZUl0ZW1zEwESBWl0ZW1zFgQSBHR5cGUSBnN0cmluZxIJbWluTGVuZ3RoAgESCW1heExlbmd0aAL7ASwSCG1heEJ5dGVzAvsBLBIIcG9zaXRpb24CBhIJa2V5UHJvb2ZzFgQSBHR5cGUSBWFycmF5EghtYXhJdGVtcwIEEgVpdGVtcxYEEgR0eXBlEgZzdHJpbmcSCW1pbkxlbmd0aAIAEgltYXhMZW5ndGgC+wSwEgdwYXR0ZXJuEhZeW0EtWmEtejAtOSsvXSo9ezAsMn0kEghwb3NpdGlvbgIHEgNib3QWBBIEdHlwZRIGb2JqZWN0Egpwcm9wZXJ0aWVzFgISCG9wZXJhdG9yFgISBHR5cGUSCmlkZW50aWZpZXISCHBvc2l0aW9uAgASCG9wZXJhdGVzFgQSBHR5cGUSBWFycmF5EghtYXhJdGVtcwIIEgVpdGVtcxYBEgR0eXBlEgppZGVudGlmaWVyEghwb3NpdGlvbgIBEhRhZGRpdGlvbmFsUHJvcGVydGllcxMAEghwb3NpdGlvbgIIEgdpbmRpY2VzFQEWAxIEbmFtZRIFb3duZXISCnByb3BlcnRpZXMVARYBEggkb3duZXJJZBIDYXNjEgZ1bmlxdWUTARIUYWRkaXRpb25hbFByb3BlcnRpZXMTAAdyZXBvS2V5FgkSBHR5cGUSBm9iamVjdBIQZG9jdW1lbnRzTXV0YWJsZRMAEgxjYW5CZURlbGV0ZWQTABINb3duZXJSZWZlcnNUbxYEEgR0eXBlEhFkZWxldGFibGVEb2N1bWVudBIMZG9jdW1lbnRUeXBlEgptYWludGFpbmVyEgZmaW5kQnkWAhIGcmVwb0lkEgZyZXBvSWQSCG1lbWJlcklkEgEuEgpjb250cmFjdElkEixEMlpMZGdnaFpUS0dwRVMzNWEzS1ZEcDVuZWNTZlpxcVJITFNrbmpSUEFWORIKcHJvcGVydGllcxYHEgZyZXBvSWQWAhIEJHJlZhIKIy8kZGVmcy9pZBIIcG9zaXRpb24CABIIbWVtYmVySWQWAxIEdHlwZRIKaWRlbnRpZmllchIIcmVmZXJzVG8WARIFYW55T2YVAhYEEgR0eXBlEhFkZWxldGFibGVEb2N1bWVudBIKY29udHJhY3RJZBIsRDJaTGRnZ2haVEtHcEVTMzVhM0tWRHA1bmVjU2ZacXFSSExTa25qUlBBVjkSDGRvY3VtZW50VHlwZRIKbWFpbnRhaW5lchIGZmluZEJ5FgISBnJlcG9JZBIGcmVwb0lkEghtZW1iZXJJZBIBLhYFEgR0eXBlEhFkZWxldGFibGVEb2N1bWVudBIKY29udHJhY3RJZBIsRDJaTGRnZ2haVEtHcEVTMzVhM0tWRHA1bmVjU2ZacXFSSExTa25qUlBBVjkSDGRvY3VtZW50VHlwZRIGd3JpdGVyEgZmaW5kQnkWAhIGcmVwb0lkEgZyZXBvSWQSCG1lbWJlcklkEgEuEgV3aGVyZRYBEgRyb2xlEgJtchIIcG9zaXRpb24CARIFZXBvY2gWAhIEJHJlZhILIy8kZGVmcy91MzISCHBvc2l0aW9uAgISDnJlY2lwaWVudEtleUlkFgUSBHR5cGUSB2ludGVnZXISB21pbmltdW0CABIHbWF4aW11bQL8/////xIIcG9zaXRpb24CAxIIcmVmZXJzVG8WAxIEdHlwZRIRaWRlbnRpdHlQdWJsaWNLZXkSEGlkZW50aXR5UHJvcGVydHkSCG1lbWJlcklkEg9rZXlSZXF1aXJlbWVudHMWARIHcHVycG9zZRIKZW5jcnlwdGlvbhILc2VuZGVyS2V5SWQWBRIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIAEgdtYXhpbXVtAvz/////EghyZWZlcnNUbxYDEgR0eXBlEhFpZGVudGl0eVB1YmxpY0tleRIQaWRlbnRpdHlQcm9wZXJ0eRIIJG93bmVySWQSD2tleVJlcXVpcmVtZW50cxYBEgdwdXJwb3NlEgplbmNyeXB0aW9uEghwb3NpdGlvbgIEEgd3cmFwcGVkFgYSBHR5cGUSBWFycmF5EglieXRlQXJyYXkTARIIbWluSXRlbXMCIBIIbWF4SXRlbXMCYBIMZW5jcnlwdGVkRm9yFgQSCXJlY2lwaWVudBIIbWVtYmVySWQSDHJlY2lwaWVudEtleRIOcmVjaXBpZW50S2V5SWQSCXNlbmRlcktleRILc2VuZGVyS2V5SWQSBnNjaGVtZRIZZWNkaC1zZWNwMjU2azEtYWVzMjU2LWNiYxIIcG9zaXRpb24CBRICbXIWBBIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIBEgdtYXhpbXVtAgMSCHBvc2l0aW9uAgYSB2luZGljZXMVAhYDEgRuYW1lEgttZW1iZXJFcG9jaBIKcHJvcGVydGllcxUEFgESBnJlcG9JZBIDYXNjFgESCG1lbWJlcklkEgNhc2MWARIFZXBvY2gSA2FzYxYBEggkb3duZXJJZBIDYXNjEgZ1bmlxdWUTARYCEgRuYW1lEghieU1lbWJlchIKcHJvcGVydGllcxUBFgESCG1lbWJlcklkEgNhc2MSCHJlcXVpcmVkFQkSCiRjcmVhdGVkQXQSFSRjcmVhdGVkQXRCbG9ja0hlaWdodBIGcmVwb0lkEghtZW1iZXJJZBIFZXBvY2gSDnJlY2lwaWVudEtleUlkEgtzZW5kZXJLZXlJZBIHd3JhcHBlZBICbXISFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwASE3Byb3BlcnR5Q29uc3RyYWludHMWARIHbXJDbGFpbRYBEgJpbhUCEgJtchUDAgECAgIDBXRvcGljFggSBHR5cGUSBm9iamVjdBIQZG9jdW1lbnRzTXV0YWJsZRMAEgxjYW5CZURlbGV0ZWQTARIKcHJvcGVydGllcxYCEgZyZXBvSWQWAxIEdHlwZRIKaWRlbnRpZmllchIIcmVmZXJzVG8WBBIEdHlwZRIRcGVybWFuZW50RG9jdW1lbnQSDGRvY3VtZW50VHlwZRIEcmVwbxIFd2hlcmUWAhIIJG93bmVySWQSCCRvd25lcklkEgp2aXNpYmlsaXR5FgESBWNvbnN0EgZwdWJsaWMSCmNvbnRyYWN0SWQSLEQyWkxkZ2doWlRLR3BFUzM1YTNLVkRwNW5lY1NmWnFxUkhMU2tualJQQVY5Eghwb3NpdGlvbgIAEgRuYW1lFgYSBHR5cGUSBnN0cmluZxIJbWluTGVuZ3RoAgESCW1heExlbmd0aAIeEghtYXhCeXRlcwIeEgdwYXR0ZXJuEhheW2EtejAtOV0rKC1bYS16MC05XSspKiQSCHBvc2l0aW9uAgESB2luZGljZXMVAxYDEgRuYW1lEgZieVJlcG8SCnByb3BlcnRpZXMVAhYBEgZyZXBvSWQSA2FzYxYBEgRuYW1lEgNhc2MSBnVuaXF1ZRMBFgQSBG5hbWUSBmJ5TmFtZRIKcHJvcGVydGllcxUCFgESBG5hbWUSA2FzYxYBEgokY3JlYXRlZEF0EgNhc2MSDnJhbmdlQ291bnRhYmxlEwESD3JhbmtlZENvdW50YWJsZRYBEgJhdBIEbmFtZRYDEgRuYW1lEgdwZXJSZXBvEgpwcm9wZXJ0aWVzFQEWARIGcmVwb0lkEgNhc2MSCWNvdW50YWJsZRMBEghyZXF1aXJlZBUDEgokY3JlYXRlZEF0EgZyZXBvSWQSBG5hbWUSFGFkZGl0aW9uYWxQcm9wZXJ0aWVzEwASE3Byb3BlcnR5Q29uc3RyYWludHMWARIIYXRNb3N0MjAWARIPbGVzc1RoYW5PckVxdWFsFQIWARIHY291bnRPZhUCEgV0b3BpYxYBEgZyZXBvSWQSBnJlcG9JZAIUCnZhdWx0RW50cnkWCBIEdHlwZRIGb2JqZWN0EhBkb2N1bWVudHNNdXRhYmxlEwESDGNhbkJlRGVsZXRlZBMBEgpwcm9wZXJ0aWVzFgYSDGNyZWRlbnRpYWxJZBYFEgR0eXBlEgVhcnJheRIJYnl0ZUFycmF5EwESCG1pbkl0ZW1zAhASCG1heEl0ZW1zAvsA/xIIcG9zaXRpb24CABIMcmVjaXBpZW50S2V5FgMSBHR5cGUSBWJ5dGVzEgRzaXplAiASCHBvc2l0aW9uAgESB3ZlcnNpb24WBBIEdHlwZRIHaW50ZWdlchIHbWluaW11bQIBEgdtYXhpbXVtAvsA/xIIcG9zaXRpb24CAhIJYXV0aEtleUlkFgUSBHR5cGUSB2ludGVnZXISB21pbmltdW0CABIHbWF4aW11bQL8/////xIIcG9zaXRpb24CAxIIcmVmZXJzVG8WAxIEdHlwZRIRaWRlbnRpdHlQdWJsaWNLZXkSEGlkZW50aXR5UHJvcGVydHkSCCRvd25lcklkEg9rZXlSZXF1aXJlbWVudHMWARIHcHVycG9zZRIOYXV0aGVudGljYXRpb24SA2VuYxYDEgR0eXBlEgVieXRlcxIEc2l6ZQIgEghwb3NpdGlvbgIEEgZzZWFsZWQWBRIEdHlwZRIFYXJyYXkSCWJ5dGVBcnJheRMBEghtaW5JdGVtcwIgEghtYXhJdGVtcwL7AQASCHBvc2l0aW9uAgUSCWltbXV0YWJsZRUCEgxjcmVkZW50aWFsSWQSDHJlY2lwaWVudEtleRIHaW5kaWNlcxUBFgMSBG5hbWUSDGJ5Q3JlZGVudGlhbBIKcHJvcGVydGllcxUCFgESCCRvd25lcklkEgNhc2MWARIMY3JlZGVudGlhbElkEgNhc2MSBnVuaXF1ZRMBEghyZXF1aXJlZBUIEgokY3JlYXRlZEF0EgokdXBkYXRlZEF0EgxjcmVkZW50aWFsSWQSDHJlY2lwaWVudEtleRIHdmVyc2lvbhIJYXV0aEtleUlkEgNlbmMSBnNlYWxlZBIUYWRkaXRpb25hbFByb3BlcnRpZXMTAAH9AAABoXbuD/AB/QAAAaF/i2RYAfwACdscAfwACeq9AftNvAH7TeUAAAABVERhc2ggRm9yZ2UgdjIgbWV0YTogcmVwbyBrZXlzLCBiYW5zLCBsYWJlbHMsIHRvcGljcywgcGFjayBtaXJyb3JzLCBwcm9maWxlcywgZm9sbG93cw==" }, "7UaqHGBJBbRLJ4fUWS45cnud8PPUugJWoGTt1SKwHJ2P": { "version": 1, diff --git a/forge-contracts/deployments/testnet.json b/forge-contracts/deployments/testnet.json index 296ab7a99..1ef1e25e6 100644 --- a/forge-contracts/deployments/testnet.json +++ b/forge-contracts/deployments/testnet.json @@ -146,6 +146,21 @@ "gitCommitPushed": true, "status": "updated", "at": "2026-10-26T18:14:06.576Z" + }, + { + "contractNonce": "3", + "kind": "dataContractUpdate", + "key": "forgeMeta", + "contractId": "6arQJW8yxf7ZfqrwJU92CtzD5JoG51uWw6koR9Haqw93", + "version": 3, + "schemaHash": "b33a289792657b3c2b175fef16fae1660faa7c899a372d225e67cd165389c547", + "previousSchemaHash": "dc2e13d943036289f68027784e7fbdb3078c07b369036275278409f1919b5a5c", + "sourceSha256": "e32b1ff316dd4821a5161bf6ba2b22ae195d7dddbb039643ab07542239015448", + "transitionSha256": "6abd8de347cfef2b3076ad93d7a2bc444cefc2bfd14d09152ed03b5ef21a1446", + "gitCommit": "7562a74e6681f534790d42975e0e1687e45af12e", + "gitCommitPushed": true, + "status": "updated", + "at": "2026-10-27T22:46:43.890Z" } ], "forgeCollab": { @@ -212,7 +227,7 @@ "status": "registered", "sizeBytes": 6976, "roomBytes": 13504, - "schemaHash": "dc2e13d943036289f68027784e7fbdb3078c07b369036275278409f1919b5a5c", + "schemaHash": "b33a289792657b3c2b175fef16fae1660faa7c899a372d225e67cd165389c547", "registeredSchemaHash": "57e35d9709a6c2e251766e02efd83e828185fb03a77755266a752a6ec586aab3", "documentsHash": "dd5e5f4ddbd8d8867ccdb9a789c9186e82fc4213b4c58dc724bb8a0a019205a9", "sourceFile": "forge-contracts/contracts/mainnet/forge-meta.json", @@ -248,9 +263,26 @@ "costCredits": "39040993330", "costDash": 0.3904099333, "updatedAt": "2026-10-26T18:14:08.493Z" + }, + { + "version": 3, + "identityNonce": "3", + "sizeBytes": 10913, + "transitionSha256": "6abd8de347cfef2b3076ad93d7a2bc444cefc2bfd14d09152ed03b5ef21a1446", + "schemaHash": "b33a289792657b3c2b175fef16fae1660faa7c899a372d225e67cd165389c547", + "previousSchemaHash": "dc2e13d943036289f68027784e7fbdb3078c07b369036275278409f1919b5a5c", + "sourceFile": "forge-contracts/contracts/mainnet/forge-meta.json", + "sourceSha256": "e32b1ff316dd4821a5161bf6ba2b22ae195d7dddbb039643ab07542239015448", + "gitCommit": "7562a74e6681f534790d42975e0e1687e45af12e", + "gitCommitPushed": true, + "balanceBefore": "73487915680", + "status": "updated", + "costCredits": "46117488830", + "costDash": 0.4611748883, + "updatedAt": "2026-10-27T22:46:47.853Z" } ], - "version": 2 + "version": 3 }, "contractGroupId": "EXgzBMpwC7RMjSU4WQghLAnfboswsssMGiXRtiV1hmBC", "contractGroup": { diff --git a/forge-contracts/evidence/testnet/README.md b/forge-contracts/evidence/testnet/README.md index 5533fce7e..fb677ae63 100644 --- a/forge-contracts/evidence/testnet/README.md +++ b/forge-contracts/evidence/testnet/README.md @@ -40,3 +40,69 @@ contract gained after the key was bound to the group), a fresh device signed in alone, then the test re-sealed one entry and deleted both. The same test then passed against the live set. Fees measured on the live set, in credits: first entry 51,513,300, a later one 33,110,400, a re-seal 3,143,380; the two deletes refunded 26,654,372 and 37,031,569; the sign-in cost nothing. + +## forge-meta update to version 3: boards (2026-10-27) + +forge-meta was updated in place to add the `board` and `card` document types (UPDATE-3, the flag `boards`, +[docs/design/boards.md](../../../docs/design/boards.md) §3), nothing else: the new forge-meta.json +differs from version 2's only by the two added types (every other type, `schemaDefs`, the config and +the description are equal), and `contract-validate --expect-update` accepts it as an update of +version 2 (`ALLOWED`). The update is one `DataContractUpdate` of 10,913 B (the contract is +10,842 B), signed by the deployer at contract nonce 3 (gitCommit `7562a74e`), costing +0.461175 tDASH (46,117,488,830 credits): a contract update pays the whole contract's registration +fee again (10 types and 16 indexes). The other three contracts are unchanged. It is recorded in +`forge-contracts/deployments/testnet.json` (`forgeMeta.updates`, `v2.nonceLedger`), and the web +snapshot (`deployments/contracts/testnet.json`) was refreshed at protocol 14 right after it. + +| File | What it shows | +|---|---| +| `update-meta-v3.sha256` | The sums of the set the update was run against (`--expect-sha256`): only forge-meta's differs from `update-meta-v2.sha256`. | +| `c1-v3.json` | C1 on the live set after the update: every contract on chain equals the signed JSON, forge-meta at version 3 (44/44). | +| `rehearsal-scratch-record.json` | The update applied to the scratch set (`forgeMeta.updates`, version 3: contract nonce 3, 10,913 B, 0.461175 tDASH). The record's top-level `sizeBytes` and `roomBytes` stay the registration's (6,976 B); the contract is now 10,842 B, about 9.6 KB under the transition limit. | +| `rehearsal-c1-v3.json` | C1 on the scratch set after the update: every contract on chain equals the signed JSON, forge-meta at version 3 (44/44). | + +**The scratch rehearsal.** The scratch set's forge-meta (`8qj74sQt…`) was updated to version 3 +with the same bytes. The first run's version check read a node that had not applied the block yet +(it still proved version 2) and stopped with the update recorded as pending; the update had +landed, and rerunning the same command completed the record. `deploy-v2.mjs` now reads the version +again for a few seconds, both after a broadcast and before rebroadcasting a pending update. + +Then `forge-web/lib/repo/boards.live.test.ts` passed three times against the scratch set +(`FORGE_BOARDS_RECORD` names its record), with the testnet QA identities OWNER (the repository's +owner), CONTRIB (granted triage) and TREASURY (a stranger). It ran the web's data layer end to end +in a throwaway repository: a board created, renamed, closed (a card write then refused before +signing), reopened, and a second one deleted; cards placed, moved with a rank, given field values +and archived; the triage member placing a card. `readBoards`, `readBoard`, `readCardsSince`, +`readItemCards` and the fold agreed with what was written. Consensus refused, each paying only a +processing fee: + +- a stranger's card and board: the member gate (40120); +- a board signed by the triage member: its writer document's role is not the claimed `r` (40127); +- the triage member's replace of its own card after the owner removed it: the gate is checked + again on a replace (40120); +- a member's card naming the repository document instead of an issue or PR: `card.item`'s + reference (40120). + +Fees the live test measured on the scratch set, in credits (three runs): + +| Write | Credits | +|---|---| +| A board with the Kanban template's definition (738 B): a repository's first | 62,769,780 to 63,818,180 | +| A repository's later board | 53,713,440 to 54,681,460 | +| A board's rename / close / reopen / delete (replaces) | 3,379,880 to 4,628,500 | +| A card for an item another member has a card for | 42,757,600 to 43,197,820 | +| An item's first card | 70,513,480 to 70,860,620 | +| A board's first card (also the item's first) | 88,333,520 to 89,120,880 | +| A card's move / field change / archive (replaces) | 4,157,662 to 5,209,102 | +| A refused write (stranger, removed member, card naming no issue or PR) | 1,628,280 to 1,980,780 | + +**The live set.** After the scratch rehearsal the live forge-meta (`6arQJW8y…`) was updated with the +same bytes; C1 passed 44/44 (`c1-v3.json`). `boards.live.test.ts` then passed against the live set +(a throwaway `boards-live-*` repository of OWNER, the same identities), every refusal above +included. Its fees fell within the scratch set's ranges, in credits: a repository's first board +62,924,580, a later one 53,868,240; board replaces 3,534,680 to 4,077,560; a board's first card +88,488,320; a card for an item another member has one for 42,912,400; card replaces 4,312,462 to +4,689,622; refused writes 1,641,280 to 2,135,580. Two writes paid more than on the scratch set, for +a reason not established here: the triage member's first card (the item's first) 79,191,280 +(70.5M-70.9M there; still under its preview with the contract-nonce surcharge, 88.5M), and the +stranger's first refused card 10,257,440 (its refused board right after it paid 1,641,280). diff --git a/forge-contracts/evidence/testnet/c1-v3.json b/forge-contracts/evidence/testnet/c1-v3.json new file mode 100644 index 000000000..8f3728740 --- /dev/null +++ b/forge-contracts/evidence/testnet/c1-v3.json @@ -0,0 +1,534 @@ +{ + "record": { + "contractsSet": "mainnet", + "forgeCore": { + "contractId": "D2ZLdgghZTKGpES35a3KVDp5necSfZqqRHLSknjRPAV9", + "ownerId": "3pjHaytsQJg5aKZj3VeqwBPccN7uN3bCJiUNkT8KUBwM", + "identityNonce": "1", + "contractGroupId": "EXgzBMpwC7RMjSU4WQghLAnfboswsssMGiXRtiV1hmBC", + "status": "registered", + "sizeBytes": 16362, + "roomBytes": 4118, + "schemaHash": "64bf6346788602014fefb738d95aa0eb45c60995a26603e5aedd493ea6dd8445", + "registeredSchemaHash": "64bf6346788602014fefb738d95aa0eb45c60995a26603e5aedd493ea6dd8445", + "documentsHash": "726f8740c9266ae53b6bce74264e4d2d7852c6ffffeeaf66a77dde99a7a104bb", + "sourceFile": "forge-contracts/contracts/mainnet/forge-core.json", + "sourceSha256": "c280e9d4ecbcba0647c882f99ae39dbbe833e7225aa4b7d07f2c815f3e51b9a5", + "transitionSha256": "9e5256515079a1c12967c5df5ff3cfcf0701bc528d91cacb02f09953b8d7f2c9", + "gitCommit": "b4fab7c0d1e92d8074c1a5ee11a9c33eecbf86bc", + "gitCommitPushed": true, + "balanceBefore": "299846897720", + "deployedAt": "2026-10-26T06:37:48.826Z", + "costCredits": "59685612310", + "costDash": 0.5968561231, + "provedAt": { + "height": "645910", + "coreChainLockedHeight": 1579593, + "epoch": 19900, + "timeMs": "1792996666178", + "protocolVersion": 14 + } + }, + "nonceLedger": [ + { + "identityNonce": "1", + "kind": "dataContractCreate", + "key": "forgeCore", + "contractId": "D2ZLdgghZTKGpES35a3KVDp5necSfZqqRHLSknjRPAV9", + "contractGroupId": "EXgzBMpwC7RMjSU4WQghLAnfboswsssMGiXRtiV1hmBC", + "registersGroup": true, + "schemaHash": "64bf6346788602014fefb738d95aa0eb45c60995a26603e5aedd493ea6dd8445", + "documentsHash": "726f8740c9266ae53b6bce74264e4d2d7852c6ffffeeaf66a77dde99a7a104bb", + "sourceSha256": "c280e9d4ecbcba0647c882f99ae39dbbe833e7225aa4b7d07f2c815f3e51b9a5", + "transitionSha256": "9e5256515079a1c12967c5df5ff3cfcf0701bc528d91cacb02f09953b8d7f2c9", + "gitCommit": "b4fab7c0d1e92d8074c1a5ee11a9c33eecbf86bc", + "gitCommitPushed": true, + "status": "registered", + "at": "2026-10-26T06:37:45.402Z" + }, + { + "identityNonce": "2", + "kind": "dataContractCreate", + "key": "forgeCollab", + "contractId": "C5b3Hys3Zb28dfrhDzn3tNdQDNCPU2ZJYgksdgDJe7ve", + "contractGroupId": "EXgzBMpwC7RMjSU4WQghLAnfboswsssMGiXRtiV1hmBC", + "registersGroup": false, + "schemaHash": "0ef8aedc872ae2229545216096a51c4d58f83e1d6853d4c425bd4a63545b0c5c", + "documentsHash": "16f1813e947e4a9d968174abd1806668ad6b9051aec0482b1ea4401c8016afa5", + "sourceSha256": "bb7735b8d191d506edf392c3536b1ef706281fa8b50d912c9223a79c9fc1b324", + "transitionSha256": "7c9d5d94b5a2dcf996d7a374714f1a353e5789b608883e27c6ea8bfc74380c59", + "gitCommit": "b4fab7c0d1e92d8074c1a5ee11a9c33eecbf86bc", + "gitCommitPushed": true, + "status": "registered", + "at": "2026-10-26T06:37:49.004Z" + }, + { + "identityNonce": "3", + "kind": "dataContractCreate", + "key": "forgeCommunity", + "contractId": "4heUXTZDrbDsy3tqVYJJP2wLCNkqUXRZzF9VQNaRq28o", + "contractGroupId": "EXgzBMpwC7RMjSU4WQghLAnfboswsssMGiXRtiV1hmBC", + "registersGroup": false, + "schemaHash": "31a94643d39dc8c5ddda0c56ae7726ab4dea082ae29cf4cc68378a95c0fead77", + "documentsHash": "dc3bcfa01d249e98012e29c7da36f8acc1fb066d304bf761debf3439462548e4", + "sourceSha256": "77a822bda29f70a45cab0b08dc4902ce572df8a05a8e1205457330a9e19167d1", + "transitionSha256": "c61e76f4123f377f113badb24bc2c3a628eaa54f4ed2224fd0ed3337a70ef4da", + "gitCommit": "b4fab7c0d1e92d8074c1a5ee11a9c33eecbf86bc", + "gitCommitPushed": true, + "status": "registered", + "at": "2026-10-26T06:37:52.118Z" + }, + { + "identityNonce": "4", + "kind": "dataContractCreate", + "key": "forgeMeta", + "contractId": "6arQJW8yxf7ZfqrwJU92CtzD5JoG51uWw6koR9Haqw93", + "contractGroupId": "EXgzBMpwC7RMjSU4WQghLAnfboswsssMGiXRtiV1hmBC", + "registersGroup": false, + "schemaHash": "57e35d9709a6c2e251766e02efd83e828185fb03a77755266a752a6ec586aab3", + "documentsHash": "dd5e5f4ddbd8d8867ccdb9a789c9186e82fc4213b4c58dc724bb8a0a019205a9", + "sourceSha256": "04627b526c706ceec4b8356c7c83851825f95004885a5d1c59872dde9767a5b0", + "transitionSha256": "c17efb9dcb0c6514a4c91bfe3e510239d4ce58e0d117760cad7abe3ce4f9e299", + "gitCommit": "b4fab7c0d1e92d8074c1a5ee11a9c33eecbf86bc", + "gitCommitPushed": true, + "status": "registered", + "at": "2026-10-26T06:37:55.017Z" + }, + { + "contractNonce": "2", + "kind": "dataContractUpdate", + "key": "forgeMeta", + "contractId": "6arQJW8yxf7ZfqrwJU92CtzD5JoG51uWw6koR9Haqw93", + "version": 2, + "schemaHash": "dc2e13d943036289f68027784e7fbdb3078c07b369036275278409f1919b5a5c", + "previousSchemaHash": "57e35d9709a6c2e251766e02efd83e828185fb03a77755266a752a6ec586aab3", + "sourceSha256": "134e00e13430999025707c8e90171fcf886dbc6988d16e2a2fd30222b59a2a63", + "transitionSha256": "e1c93515e1858452cfe402283e70411a34a5d5dee0c0f9bb8279ce1e388bd041", + "gitCommit": "b3197b9330e62654630310d6d7abb5101c4e4a3d", + "gitCommitPushed": true, + "status": "updated", + "at": "2026-10-26T18:14:06.576Z" + }, + { + "contractNonce": "3", + "kind": "dataContractUpdate", + "key": "forgeMeta", + "contractId": "6arQJW8yxf7ZfqrwJU92CtzD5JoG51uWw6koR9Haqw93", + "version": 3, + "schemaHash": "b33a289792657b3c2b175fef16fae1660faa7c899a372d225e67cd165389c547", + "previousSchemaHash": "dc2e13d943036289f68027784e7fbdb3078c07b369036275278409f1919b5a5c", + "sourceSha256": "e32b1ff316dd4821a5161bf6ba2b22ae195d7dddbb039643ab07542239015448", + "transitionSha256": "6abd8de347cfef2b3076ad93d7a2bc444cefc2bfd14d09152ed03b5ef21a1446", + "gitCommit": "7562a74e6681f534790d42975e0e1687e45af12e", + "gitCommitPushed": true, + "status": "updated", + "at": "2026-10-27T22:46:43.890Z" + } + ], + "forgeCollab": { + "contractId": "C5b3Hys3Zb28dfrhDzn3tNdQDNCPU2ZJYgksdgDJe7ve", + "ownerId": "3pjHaytsQJg5aKZj3VeqwBPccN7uN3bCJiUNkT8KUBwM", + "identityNonce": "2", + "contractGroupId": "EXgzBMpwC7RMjSU4WQghLAnfboswsssMGiXRtiV1hmBC", + "status": "registered", + "sizeBytes": 17291, + "roomBytes": 3189, + "schemaHash": "0ef8aedc872ae2229545216096a51c4d58f83e1d6853d4c425bd4a63545b0c5c", + "registeredSchemaHash": "0ef8aedc872ae2229545216096a51c4d58f83e1d6853d4c425bd4a63545b0c5c", + "documentsHash": "16f1813e947e4a9d968174abd1806668ad6b9051aec0482b1ea4401c8016afa5", + "sourceFile": "forge-contracts/contracts/mainnet/forge-collab.json", + "sourceSha256": "bb7735b8d191d506edf392c3536b1ef706281fa8b50d912c9223a79c9fc1b324", + "transitionSha256": "7c9d5d94b5a2dcf996d7a374714f1a353e5789b608883e27c6ea8bfc74380c59", + "gitCommit": "b4fab7c0d1e92d8074c1a5ee11a9c33eecbf86bc", + "gitCommitPushed": true, + "balanceBefore": "240161285410", + "deployedAt": "2026-10-26T06:37:51.864Z", + "costCredits": "39635379480", + "costDash": 0.3963537948, + "provedAt": { + "height": "645912", + "coreChainLockedHeight": 1579593, + "epoch": 19900, + "timeMs": "1792996670055", + "protocolVersion": 14 + } + }, + "forgeCommunity": { + "contractId": "4heUXTZDrbDsy3tqVYJJP2wLCNkqUXRZzF9VQNaRq28o", + "ownerId": "3pjHaytsQJg5aKZj3VeqwBPccN7uN3bCJiUNkT8KUBwM", + "identityNonce": "3", + "contractGroupId": "EXgzBMpwC7RMjSU4WQghLAnfboswsssMGiXRtiV1hmBC", + "status": "registered", + "sizeBytes": 15651, + "roomBytes": 4829, + "schemaHash": "31a94643d39dc8c5ddda0c56ae7726ab4dea082ae29cf4cc68378a95c0fead77", + "registeredSchemaHash": "31a94643d39dc8c5ddda0c56ae7726ab4dea082ae29cf4cc68378a95c0fead77", + "documentsHash": "dc3bcfa01d249e98012e29c7da36f8acc1fb066d304bf761debf3439462548e4", + "sourceFile": "forge-contracts/contracts/mainnet/forge-community.json", + "sourceSha256": "77a822bda29f70a45cab0b08dc4902ce572df8a05a8e1205457330a9e19167d1", + "transitionSha256": "c61e76f4123f377f113badb24bc2c3a628eaa54f4ed2224fd0ed3337a70ef4da", + "gitCommit": "b4fab7c0d1e92d8074c1a5ee11a9c33eecbf86bc", + "gitCommitPushed": true, + "balanceBefore": "200525905930", + "deployedAt": "2026-10-26T06:37:54.859Z", + "costCredits": "51634980060", + "costDash": 0.5163498006, + "provedAt": { + "height": "645914", + "coreChainLockedHeight": 1579593, + "epoch": 19900, + "timeMs": "1792996672707", + "protocolVersion": 14 + } + }, + "forgeMeta": { + "contractId": "6arQJW8yxf7ZfqrwJU92CtzD5JoG51uWw6koR9Haqw93", + "ownerId": "3pjHaytsQJg5aKZj3VeqwBPccN7uN3bCJiUNkT8KUBwM", + "identityNonce": "4", + "contractGroupId": "EXgzBMpwC7RMjSU4WQghLAnfboswsssMGiXRtiV1hmBC", + "status": "registered", + "sizeBytes": 6976, + "roomBytes": 13504, + "schemaHash": "b33a289792657b3c2b175fef16fae1660faa7c899a372d225e67cd165389c547", + "registeredSchemaHash": "57e35d9709a6c2e251766e02efd83e828185fb03a77755266a752a6ec586aab3", + "documentsHash": "dd5e5f4ddbd8d8867ccdb9a789c9186e82fc4213b4c58dc724bb8a0a019205a9", + "sourceFile": "forge-contracts/contracts/mainnet/forge-meta.json", + "sourceSha256": "04627b526c706ceec4b8356c7c83851825f95004885a5d1c59872dde9767a5b0", + "transitionSha256": "c17efb9dcb0c6514a4c91bfe3e510239d4ce58e0d117760cad7abe3ce4f9e299", + "gitCommit": "b4fab7c0d1e92d8074c1a5ee11a9c33eecbf86bc", + "gitCommitPushed": true, + "balanceBefore": "148890925870", + "deployedAt": "2026-10-26T06:37:57.558Z", + "costCredits": "36362016860", + "costDash": 0.3636201686, + "provedAt": { + "height": "645916", + "coreChainLockedHeight": 1579593, + "epoch": 19900, + "timeMs": "1792996675568", + "protocolVersion": 14 + }, + "updates": [ + { + "version": 2, + "identityNonce": "2", + "sizeBytes": 7755, + "transitionSha256": "e1c93515e1858452cfe402283e70411a34a5d5dee0c0f9bb8279ce1e388bd041", + "schemaHash": "dc2e13d943036289f68027784e7fbdb3078c07b369036275278409f1919b5a5c", + "previousSchemaHash": "57e35d9709a6c2e251766e02efd83e828185fb03a77755266a752a6ec586aab3", + "sourceFile": "forge-contracts/contracts/mainnet/forge-meta.json", + "sourceSha256": "134e00e13430999025707c8e90171fcf886dbc6988d16e2a2fd30222b59a2a63", + "gitCommit": "b3197b9330e62654630310d6d7abb5101c4e4a3d", + "gitCommitPushed": true, + "balanceBefore": "112528909010", + "status": "updated", + "costCredits": "39040993330", + "costDash": 0.3904099333, + "updatedAt": "2026-10-26T18:14:08.493Z" + }, + { + "version": 3, + "identityNonce": "3", + "sizeBytes": 10913, + "transitionSha256": "6abd8de347cfef2b3076ad93d7a2bc444cefc2bfd14d09152ed03b5ef21a1446", + "schemaHash": "b33a289792657b3c2b175fef16fae1660faa7c899a372d225e67cd165389c547", + "previousSchemaHash": "dc2e13d943036289f68027784e7fbdb3078c07b369036275278409f1919b5a5c", + "sourceFile": "forge-contracts/contracts/mainnet/forge-meta.json", + "sourceSha256": "e32b1ff316dd4821a5161bf6ba2b22ae195d7dddbb039643ab07542239015448", + "gitCommit": "7562a74e6681f534790d42975e0e1687e45af12e", + "gitCommitPushed": true, + "balanceBefore": "73487915680", + "status": "updated", + "costCredits": "46117488830", + "costDash": 0.4611748883, + "updatedAt": "2026-10-27T22:46:47.853Z" + } + ], + "version": 3 + }, + "contractGroupId": "EXgzBMpwC7RMjSU4WQghLAnfboswsssMGiXRtiV1hmBC", + "contractGroup": { + "id": "EXgzBMpwC7RMjSU4WQghLAnfboswsssMGiXRtiV1hmBC", + "name": "dash-forge", + "owner": "3pjHaytsQJg5aKZj3VeqwBPccN7uN3bCJiUNkT8KUBwM", + "admins": [], + "description": "Dash Forge v2: forge-core, forge-collab, forge-community and forge-meta", + "verifiedAt": "2026-10-26T06:37:58.041Z" + }, + "protocolVersion": 14, + "sdk": "@dashevo/evo-sdk@5.0.0-rc.8", + "deployer": { + "identityId": "3pjHaytsQJg5aKZj3VeqwBPccN7uN3bCJiUNkT8KUBwM", + "assetLockTxid": "296c023860eb2f397eb4d842ff0c3a05d35fb8b300c9657b18ef5bd4b1e5e1f4", + "createdAtHeight": 1579542, + "note": "custody: offline escrow (OD-2); never signs anything but Forge contract registrations and updates" + }, + "restores": [] + }, + "results": [ + { + "contract": "forge-core", + "name": "registered on chain", + "pass": true, + "detail": "D2ZLdgghZTKGpES35a3KVDp5necSfZqqRHLSknjRPAV9 version 1" + }, + { + "contract": "forge-core", + "name": "owner is the deployer and version is 1 (recorded)", + "pass": true, + "detail": "3pjHaytsQJg5aKZj3VeqwBPccN7uN3bCJiUNkT8KUBwM v1" + }, + { + "contract": "forge-core", + "name": "config $formatVersion 2", + "pass": true, + "detail": "2" + }, + { + "contract": "forge-core", + "name": "readonly false", + "pass": true, + "detail": "false" + }, + { + "contract": "forge-core", + "name": "canBeDeleted false, keepsHistory false (no moderation)", + "pass": true, + "detail": "{\"canBeDeleted\":false,\"keepsHistory\":false}" + }, + { + "contract": "forge-core", + "name": "config keys beyond the JSON block are unset defaults (null)", + "pass": true, + "detail": "{\"requiresIdentityEncryptionBoundedKey\":null,\"requiresIdentityDecryptionBoundedKey\":null}" + }, + { + "contract": "forge-core", + "name": "config equals the JSON block", + "pass": true, + "detail": "" + }, + { + "contract": "forge-core", + "name": "same document types", + "pass": true, + "detail": "11 types on chain, 11 in the JSON" + }, + { + "contract": "forge-core", + "name": "every documentSchema equals the JSON (ids substituted)", + "pass": true, + "detail": "sha256 fabb387491fc == fabb387491fc" + }, + { + "contract": "forge-core", + "name": "schemaDefs equal the JSON", + "pass": true, + "detail": "" + }, + { + "contract": "forge-core", + "name": "recorded schemaHash is the substituted JSON's", + "pass": true, + "detail": "64bf63467886" + }, + { + "contract": "forge-collab", + "name": "registered on chain", + "pass": true, + "detail": "C5b3Hys3Zb28dfrhDzn3tNdQDNCPU2ZJYgksdgDJe7ve version 1" + }, + { + "contract": "forge-collab", + "name": "owner is the deployer and version is 1 (recorded)", + "pass": true, + "detail": "3pjHaytsQJg5aKZj3VeqwBPccN7uN3bCJiUNkT8KUBwM v1" + }, + { + "contract": "forge-collab", + "name": "config $formatVersion 2", + "pass": true, + "detail": "2" + }, + { + "contract": "forge-collab", + "name": "readonly false", + "pass": true, + "detail": "false" + }, + { + "contract": "forge-collab", + "name": "canBeDeleted false, keepsHistory false (no moderation)", + "pass": true, + "detail": "{\"canBeDeleted\":false,\"keepsHistory\":false}" + }, + { + "contract": "forge-collab", + "name": "config keys beyond the JSON block are unset defaults (null)", + "pass": true, + "detail": "{\"requiresIdentityEncryptionBoundedKey\":null,\"requiresIdentityDecryptionBoundedKey\":null}" + }, + { + "contract": "forge-collab", + "name": "config equals the JSON block", + "pass": true, + "detail": "" + }, + { + "contract": "forge-collab", + "name": "same document types", + "pass": true, + "detail": "5 types on chain, 5 in the JSON" + }, + { + "contract": "forge-collab", + "name": "every documentSchema equals the JSON (ids substituted)", + "pass": true, + "detail": "sha256 4d1bacef27bb == 4d1bacef27bb" + }, + { + "contract": "forge-collab", + "name": "schemaDefs equal the JSON", + "pass": true, + "detail": "" + }, + { + "contract": "forge-collab", + "name": "recorded schemaHash is the substituted JSON's", + "pass": true, + "detail": "0ef8aedc872a" + }, + { + "contract": "forge-community", + "name": "registered on chain", + "pass": true, + "detail": "4heUXTZDrbDsy3tqVYJJP2wLCNkqUXRZzF9VQNaRq28o version 1" + }, + { + "contract": "forge-community", + "name": "owner is the deployer and version is 1 (recorded)", + "pass": true, + "detail": "3pjHaytsQJg5aKZj3VeqwBPccN7uN3bCJiUNkT8KUBwM v1" + }, + { + "contract": "forge-community", + "name": "config $formatVersion 2", + "pass": true, + "detail": "2" + }, + { + "contract": "forge-community", + "name": "readonly false", + "pass": true, + "detail": "false" + }, + { + "contract": "forge-community", + "name": "canBeDeleted false, keepsHistory false (no moderation)", + "pass": true, + "detail": "{\"canBeDeleted\":false,\"keepsHistory\":false}" + }, + { + "contract": "forge-community", + "name": "config keys beyond the JSON block are unset defaults (null)", + "pass": true, + "detail": "{\"requiresIdentityEncryptionBoundedKey\":null,\"requiresIdentityDecryptionBoundedKey\":null}" + }, + { + "contract": "forge-community", + "name": "config equals the JSON block", + "pass": true, + "detail": "" + }, + { + "contract": "forge-community", + "name": "same document types", + "pass": true, + "detail": "9 types on chain, 9 in the JSON" + }, + { + "contract": "forge-community", + "name": "every documentSchema equals the JSON (ids substituted)", + "pass": true, + "detail": "sha256 4fa77dbc470b == 4fa77dbc470b" + }, + { + "contract": "forge-community", + "name": "schemaDefs equal the JSON", + "pass": true, + "detail": "" + }, + { + "contract": "forge-community", + "name": "recorded schemaHash is the substituted JSON's", + "pass": true, + "detail": "31a94643d39d" + }, + { + "contract": "forge-meta", + "name": "registered on chain", + "pass": true, + "detail": "6arQJW8yxf7ZfqrwJU92CtzD5JoG51uWw6koR9Haqw93 version 3" + }, + { + "contract": "forge-meta", + "name": "owner is the deployer and version is 3 (recorded)", + "pass": true, + "detail": "3pjHaytsQJg5aKZj3VeqwBPccN7uN3bCJiUNkT8KUBwM v3" + }, + { + "contract": "forge-meta", + "name": "config $formatVersion 2", + "pass": true, + "detail": "2" + }, + { + "contract": "forge-meta", + "name": "readonly false", + "pass": true, + "detail": "false" + }, + { + "contract": "forge-meta", + "name": "canBeDeleted false, keepsHistory false (no moderation)", + "pass": true, + "detail": "{\"canBeDeleted\":false,\"keepsHistory\":false}" + }, + { + "contract": "forge-meta", + "name": "config keys beyond the JSON block are unset defaults (null)", + "pass": true, + "detail": "{\"requiresIdentityEncryptionBoundedKey\":null,\"requiresIdentityDecryptionBoundedKey\":null}" + }, + { + "contract": "forge-meta", + "name": "config equals the JSON block", + "pass": true, + "detail": "" + }, + { + "contract": "forge-meta", + "name": "same document types", + "pass": true, + "detail": "10 types on chain, 10 in the JSON" + }, + { + "contract": "forge-meta", + "name": "every documentSchema equals the JSON (ids substituted)", + "pass": true, + "detail": "sha256 35ec34165986 == 35ec34165986" + }, + { + "contract": "forge-meta", + "name": "schemaDefs equal the JSON", + "pass": true, + "detail": "" + }, + { + "contract": "forge-meta", + "name": "recorded schemaHash is the substituted JSON's", + "pass": true, + "detail": "b33a28979265" + } + ] +} diff --git a/forge-contracts/evidence/testnet/rehearsal-c1-v3.json b/forge-contracts/evidence/testnet/rehearsal-c1-v3.json new file mode 100644 index 000000000..2ed152020 --- /dev/null +++ b/forge-contracts/evidence/testnet/rehearsal-c1-v3.json @@ -0,0 +1,536 @@ +{ + "record": { + "contractsSet": "mainnet", + "forgeCore": { + "contractId": "9bXpqgEppfxG2Z4um8Y6T9miARJMKJZqoPDnrUss2fbP", + "ownerId": "CCFcNqhKo9H3Jo9TRdeBBhD1mpfehWmTYd6a4hpfqdeX", + "identityNonce": "1", + "contractGroupId": "28WdQQm2kF5PH3oQonjJSQUsd9QuXbSDATuFiAKdQqm4", + "status": "registered", + "sizeBytes": 16362, + "roomBytes": 4118, + "schemaHash": "64bf6346788602014fefb738d95aa0eb45c60995a26603e5aedd493ea6dd8445", + "registeredSchemaHash": "64bf6346788602014fefb738d95aa0eb45c60995a26603e5aedd493ea6dd8445", + "documentsHash": "726f8740c9266ae53b6bce74264e4d2d7852c6ffffeeaf66a77dde99a7a104bb", + "sourceFile": "forge-contracts/contracts/mainnet/forge-core.json", + "sourceSha256": "c280e9d4ecbcba0647c882f99ae39dbbe833e7225aa4b7d07f2c815f3e51b9a5", + "transitionSha256": "723c4dc705fab7a92ede2a9433c4f675ef6096a6d6f1f63eaf09d7176bb9d8ec", + "gitCommit": "bbeda1a5ce77b37890935c3a360804e3c15f4740", + "gitCommitPushed": true, + "balanceBefore": "199856605820", + "deployedAt": "2026-10-26T04:40:11.125Z", + "costCredits": "59685417030", + "costDash": 0.5968541703, + "provedAt": { + "height": "645106", + "coreChainLockedHeight": 1579547, + "epoch": 19898, + "timeMs": "1792989607824", + "protocolVersion": 14 + } + }, + "nonceLedger": [ + { + "identityNonce": "1", + "kind": "dataContractCreate", + "key": "forgeCore", + "contractId": "9bXpqgEppfxG2Z4um8Y6T9miARJMKJZqoPDnrUss2fbP", + "contractGroupId": "28WdQQm2kF5PH3oQonjJSQUsd9QuXbSDATuFiAKdQqm4", + "registersGroup": true, + "schemaHash": "64bf6346788602014fefb738d95aa0eb45c60995a26603e5aedd493ea6dd8445", + "documentsHash": "726f8740c9266ae53b6bce74264e4d2d7852c6ffffeeaf66a77dde99a7a104bb", + "sourceSha256": "c280e9d4ecbcba0647c882f99ae39dbbe833e7225aa4b7d07f2c815f3e51b9a5", + "transitionSha256": "723c4dc705fab7a92ede2a9433c4f675ef6096a6d6f1f63eaf09d7176bb9d8ec", + "gitCommit": "bbeda1a5ce77b37890935c3a360804e3c15f4740", + "gitCommitPushed": true, + "status": "registered", + "at": "2026-10-26T04:40:07.572Z" + }, + { + "identityNonce": "2", + "kind": "dataContractCreate", + "key": "forgeCollab", + "contractId": "8SQr4F8jE3kgwoYUWWDAAT3kDeJEFU3ESQjBLkYZtLCz", + "contractGroupId": "28WdQQm2kF5PH3oQonjJSQUsd9QuXbSDATuFiAKdQqm4", + "registersGroup": false, + "schemaHash": "98711a7919991600db87eb206ae9469919502faee40e2e9cd0e3c6abc6e678f3", + "documentsHash": "8131d5eb56d2481979ffdda53d0a3519c8fe6a67011552d3b0c58e18c7036662", + "sourceSha256": "bb7735b8d191d506edf392c3536b1ef706281fa8b50d912c9223a79c9fc1b324", + "transitionSha256": "0cea4d7534abdb628931fa369aa8ac6309d7fbd6bf9de9d88662299035a87866", + "gitCommit": "bbeda1a5ce77b37890935c3a360804e3c15f4740", + "gitCommitPushed": true, + "status": "registered", + "at": "2026-10-26T04:40:11.376Z" + }, + { + "identityNonce": "3", + "kind": "dataContractCreate", + "key": "forgeCommunity", + "contractId": "68HtWxTtbgFjHNnkBXKP72J3ikxdieT2EY4bsuGz7Zpp", + "contractGroupId": "28WdQQm2kF5PH3oQonjJSQUsd9QuXbSDATuFiAKdQqm4", + "registersGroup": false, + "schemaHash": "833610faa0c638f0f37ffcdddde5674c3034ef5873d687dac6228b6f52f454e7", + "documentsHash": "71096b18b7e1f503c3daa7218de47b658bd3cb1de53ea1ee2d75c75d9f420004", + "sourceSha256": "77a822bda29f70a45cab0b08dc4902ce572df8a05a8e1205457330a9e19167d1", + "transitionSha256": "7e09a2973c97fb0104241314f6a3779d52543476b9d9a7fce1d97feb2c286943", + "gitCommit": "bbeda1a5ce77b37890935c3a360804e3c15f4740", + "gitCommitPushed": true, + "status": "registered", + "at": "2026-10-26T04:40:15.296Z" + }, + { + "identityNonce": "4", + "kind": "dataContractCreate", + "key": "forgeMeta", + "contractId": "8qj74sQtGWq5Rwf5ihgNibD2tkwX61JLqvbkN2mhgcYT", + "contractGroupId": "28WdQQm2kF5PH3oQonjJSQUsd9QuXbSDATuFiAKdQqm4", + "registersGroup": false, + "schemaHash": "3d5d945028fd3aae71971ddac686f415a563e89c26ec9ab100716c9642a6d8ee", + "documentsHash": "aa8ad5d399810339528a33ba7bc1915f9c587ab00689b2a0a279272ce9b1a8dc", + "sourceSha256": "04627b526c706ceec4b8356c7c83851825f95004885a5d1c59872dde9767a5b0", + "transitionSha256": "f86bad0c282e379609bc302e123a1303ca63b36f2135af3300b31079b26937c8", + "gitCommit": "bbeda1a5ce77b37890935c3a360804e3c15f4740", + "gitCommitPushed": true, + "status": "registered", + "at": "2026-10-26T04:40:17.823Z" + }, + { + "contractNonce": "2", + "kind": "dataContractUpdate", + "key": "forgeMeta", + "contractId": "8qj74sQtGWq5Rwf5ihgNibD2tkwX61JLqvbkN2mhgcYT", + "version": 2, + "schemaHash": "7c46bde00abab29a095bcce067f674f25e68b8dce4b3502bda9dec42bd3394dc", + "previousSchemaHash": "3d5d945028fd3aae71971ddac686f415a563e89c26ec9ab100716c9642a6d8ee", + "sourceSha256": "134e00e13430999025707c8e90171fcf886dbc6988d16e2a2fd30222b59a2a63", + "transitionSha256": "0f50b36dd12b587ab11eb307680c4586260f919b9fd9e81521be7b15888fe337", + "gitCommit": "b3197b9330e62654630310d6d7abb5101c4e4a3d", + "gitCommitPushed": true, + "status": "updated", + "at": "2026-10-26T18:09:54.434Z" + }, + { + "contractNonce": "3", + "kind": "dataContractUpdate", + "key": "forgeMeta", + "contractId": "8qj74sQtGWq5Rwf5ihgNibD2tkwX61JLqvbkN2mhgcYT", + "version": 3, + "schemaHash": "37773c7b0ea5fdd24dcd38ca84f4892ce49d179d3ba952ea3ce128e5bdfd194c", + "previousSchemaHash": "7c46bde00abab29a095bcce067f674f25e68b8dce4b3502bda9dec42bd3394dc", + "sourceSha256": "e32b1ff316dd4821a5161bf6ba2b22ae195d7dddbb039643ab07542239015448", + "transitionSha256": "4a928eb3d47cfc62440c1cc3a5e27d8d90ea72377a6b58ba1dc1c84d4795b9d9", + "gitCommit": "c49f8966f7e7f21dfc6cd9a66a82a10fadc44f5a", + "gitCommitPushed": false, + "status": "updated", + "at": "2026-10-27T22:15:36.844Z" + } + ], + "forgeCollab": { + "contractId": "8SQr4F8jE3kgwoYUWWDAAT3kDeJEFU3ESQjBLkYZtLCz", + "ownerId": "CCFcNqhKo9H3Jo9TRdeBBhD1mpfehWmTYd6a4hpfqdeX", + "identityNonce": "2", + "contractGroupId": "28WdQQm2kF5PH3oQonjJSQUsd9QuXbSDATuFiAKdQqm4", + "status": "registered", + "sizeBytes": 17291, + "roomBytes": 3189, + "schemaHash": "98711a7919991600db87eb206ae9469919502faee40e2e9cd0e3c6abc6e678f3", + "registeredSchemaHash": "98711a7919991600db87eb206ae9469919502faee40e2e9cd0e3c6abc6e678f3", + "documentsHash": "8131d5eb56d2481979ffdda53d0a3519c8fe6a67011552d3b0c58e18c7036662", + "sourceFile": "forge-contracts/contracts/mainnet/forge-collab.json", + "sourceSha256": "bb7735b8d191d506edf392c3536b1ef706281fa8b50d912c9223a79c9fc1b324", + "transitionSha256": "0cea4d7534abdb628931fa369aa8ac6309d7fbd6bf9de9d88662299035a87866", + "gitCommit": "bbeda1a5ce77b37890935c3a360804e3c15f4740", + "gitCommitPushed": true, + "balanceBefore": "140171188790", + "deployedAt": "2026-10-26T04:40:15.127Z", + "costCredits": "39635008160", + "costDash": 0.3963500816, + "provedAt": { + "height": "645107", + "coreChainLockedHeight": 1579547, + "epoch": 19899, + "timeMs": "1792989611492", + "protocolVersion": 14 + } + }, + "forgeCommunity": { + "contractId": "68HtWxTtbgFjHNnkBXKP72J3ikxdieT2EY4bsuGz7Zpp", + "ownerId": "CCFcNqhKo9H3Jo9TRdeBBhD1mpfehWmTYd6a4hpfqdeX", + "identityNonce": "3", + "contractGroupId": "28WdQQm2kF5PH3oQonjJSQUsd9QuXbSDATuFiAKdQqm4", + "status": "registered", + "sizeBytes": 15651, + "roomBytes": 4829, + "schemaHash": "833610faa0c638f0f37ffcdddde5674c3034ef5873d687dac6228b6f52f454e7", + "registeredSchemaHash": "833610faa0c638f0f37ffcdddde5674c3034ef5873d687dac6228b6f52f454e7", + "documentsHash": "71096b18b7e1f503c3daa7218de47b658bd3cb1de53ea1ee2d75c75d9f420004", + "sourceFile": "forge-contracts/contracts/mainnet/forge-community.json", + "sourceSha256": "77a822bda29f70a45cab0b08dc4902ce572df8a05a8e1205457330a9e19167d1", + "transitionSha256": "7e09a2973c97fb0104241314f6a3779d52543476b9d9a7fce1d97feb2c286943", + "gitCommit": "bbeda1a5ce77b37890935c3a360804e3c15f4740", + "gitCommitPushed": true, + "balanceBefore": "100536180630", + "deployedAt": "2026-10-26T04:40:17.662Z", + "costCredits": "51634780820", + "costDash": 0.5163478082, + "provedAt": { + "height": "645108", + "coreChainLockedHeight": 1579547, + "epoch": 19899, + "timeMs": "1792989615519", + "protocolVersion": 14 + } + }, + "forgeMeta": { + "contractId": "8qj74sQtGWq5Rwf5ihgNibD2tkwX61JLqvbkN2mhgcYT", + "ownerId": "CCFcNqhKo9H3Jo9TRdeBBhD1mpfehWmTYd6a4hpfqdeX", + "identityNonce": "4", + "contractGroupId": "28WdQQm2kF5PH3oQonjJSQUsd9QuXbSDATuFiAKdQqm4", + "status": "registered", + "sizeBytes": 6976, + "roomBytes": 13504, + "schemaHash": "37773c7b0ea5fdd24dcd38ca84f4892ce49d179d3ba952ea3ce128e5bdfd194c", + "registeredSchemaHash": "3d5d945028fd3aae71971ddac686f415a563e89c26ec9ab100716c9642a6d8ee", + "documentsHash": "aa8ad5d399810339528a33ba7bc1915f9c587ab00689b2a0a279272ce9b1a8dc", + "sourceFile": "forge-contracts/contracts/mainnet/forge-meta.json", + "sourceSha256": "04627b526c706ceec4b8356c7c83851825f95004885a5d1c59872dde9767a5b0", + "transitionSha256": "f86bad0c282e379609bc302e123a1303ca63b36f2135af3300b31079b26937c8", + "gitCommit": "bbeda1a5ce77b37890935c3a360804e3c15f4740", + "gitCommitPushed": true, + "balanceBefore": "48901399810", + "deployedAt": "2026-10-26T04:40:22.041Z", + "costCredits": "36362313960", + "costDash": 0.3636231396, + "provedAt": { + "height": "645110", + "coreChainLockedHeight": 1579547, + "epoch": 19899, + "timeMs": "1792989619768", + "protocolVersion": 14 + }, + "updates": [ + { + "version": 2, + "identityNonce": "2", + "sizeBytes": 7755, + "transitionSha256": "0f50b36dd12b587ab11eb307680c4586260f919b9fd9e81521be7b15888fe337", + "schemaHash": "7c46bde00abab29a095bcce067f674f25e68b8dce4b3502bda9dec42bd3394dc", + "previousSchemaHash": "3d5d945028fd3aae71971ddac686f415a563e89c26ec9ab100716c9642a6d8ee", + "sourceFile": "forge-contracts/contracts/mainnet/forge-meta.json", + "sourceSha256": "134e00e13430999025707c8e90171fcf886dbc6988d16e2a2fd30222b59a2a63", + "gitCommit": "b3197b9330e62654630310d6d7abb5101c4e4a3d", + "gitCommitPushed": true, + "balanceBefore": "62530018690", + "status": "updated", + "costCredits": "39040977570", + "costDash": 0.3904097757, + "updatedAt": "2026-10-26T18:10:00.225Z" + }, + { + "version": 3, + "identityNonce": "3", + "sizeBytes": 10913, + "transitionSha256": "4a928eb3d47cfc62440c1cc3a5e27d8d90ea72377a6b58ba1dc1c84d4795b9d9", + "schemaHash": "37773c7b0ea5fdd24dcd38ca84f4892ce49d179d3ba952ea3ce128e5bdfd194c", + "previousSchemaHash": "7c46bde00abab29a095bcce067f674f25e68b8dce4b3502bda9dec42bd3394dc", + "sourceFile": "forge-contracts/contracts/mainnet/forge-meta.json", + "sourceSha256": "e32b1ff316dd4821a5161bf6ba2b22ae195d7dddbb039643ab07542239015448", + "gitCommit": "c49f8966f7e7f21dfc6cd9a66a82a10fadc44f5a", + "gitCommitPushed": false, + "balanceBefore": "58479972440", + "status": "updated", + "costCredits": "46117473070", + "costDash": 0.4611747307, + "confirmedAt": "2026-10-27T22:16:32.602Z", + "costNote": "balance delta since the recorded pre-broadcast balance" + } + ], + "version": 3 + }, + "contractGroupId": "28WdQQm2kF5PH3oQonjJSQUsd9QuXbSDATuFiAKdQqm4", + "contractGroup": { + "id": "28WdQQm2kF5PH3oQonjJSQUsd9QuXbSDATuFiAKdQqm4", + "name": "dash-forge", + "owner": "CCFcNqhKo9H3Jo9TRdeBBhD1mpfehWmTYd6a4hpfqdeX", + "admins": [], + "description": "Dash Forge v2: forge-core, forge-collab, forge-community and forge-meta", + "verifiedAt": "2026-10-26T04:40:22.491Z" + }, + "protocolVersion": 14, + "sdk": "@dashevo/evo-sdk@5.0.0-rc.8", + "deployer": { + "identityId": "CCFcNqhKo9H3Jo9TRdeBBhD1mpfehWmTYd6a4hpfqdeX", + "assetLockTxid": "c93ee02d7a45abe906dc3693203252b469fbcaa1089f866861d2f47e239d396a", + "createdAtHeight": null, + "note": "custody: offline escrow (OD-2); never signs anything but Forge contract registrations and updates" + }, + "restores": [], + "scratchOn": "testnet" + }, + "results": [ + { + "contract": "forge-core", + "name": "registered on chain", + "pass": true, + "detail": "9bXpqgEppfxG2Z4um8Y6T9miARJMKJZqoPDnrUss2fbP version 1" + }, + { + "contract": "forge-core", + "name": "owner is the deployer and version is 1 (recorded)", + "pass": true, + "detail": "CCFcNqhKo9H3Jo9TRdeBBhD1mpfehWmTYd6a4hpfqdeX v1" + }, + { + "contract": "forge-core", + "name": "config $formatVersion 2", + "pass": true, + "detail": "2" + }, + { + "contract": "forge-core", + "name": "readonly false", + "pass": true, + "detail": "false" + }, + { + "contract": "forge-core", + "name": "canBeDeleted false, keepsHistory false (no moderation)", + "pass": true, + "detail": "{\"canBeDeleted\":false,\"keepsHistory\":false}" + }, + { + "contract": "forge-core", + "name": "config keys beyond the JSON block are unset defaults (null)", + "pass": true, + "detail": "{\"requiresIdentityEncryptionBoundedKey\":null,\"requiresIdentityDecryptionBoundedKey\":null}" + }, + { + "contract": "forge-core", + "name": "config equals the JSON block", + "pass": true, + "detail": "" + }, + { + "contract": "forge-core", + "name": "same document types", + "pass": true, + "detail": "11 types on chain, 11 in the JSON" + }, + { + "contract": "forge-core", + "name": "every documentSchema equals the JSON (ids substituted)", + "pass": true, + "detail": "sha256 fabb387491fc == fabb387491fc" + }, + { + "contract": "forge-core", + "name": "schemaDefs equal the JSON", + "pass": true, + "detail": "" + }, + { + "contract": "forge-core", + "name": "recorded schemaHash is the substituted JSON's", + "pass": true, + "detail": "64bf63467886" + }, + { + "contract": "forge-collab", + "name": "registered on chain", + "pass": true, + "detail": "8SQr4F8jE3kgwoYUWWDAAT3kDeJEFU3ESQjBLkYZtLCz version 1" + }, + { + "contract": "forge-collab", + "name": "owner is the deployer and version is 1 (recorded)", + "pass": true, + "detail": "CCFcNqhKo9H3Jo9TRdeBBhD1mpfehWmTYd6a4hpfqdeX v1" + }, + { + "contract": "forge-collab", + "name": "config $formatVersion 2", + "pass": true, + "detail": "2" + }, + { + "contract": "forge-collab", + "name": "readonly false", + "pass": true, + "detail": "false" + }, + { + "contract": "forge-collab", + "name": "canBeDeleted false, keepsHistory false (no moderation)", + "pass": true, + "detail": "{\"canBeDeleted\":false,\"keepsHistory\":false}" + }, + { + "contract": "forge-collab", + "name": "config keys beyond the JSON block are unset defaults (null)", + "pass": true, + "detail": "{\"requiresIdentityEncryptionBoundedKey\":null,\"requiresIdentityDecryptionBoundedKey\":null}" + }, + { + "contract": "forge-collab", + "name": "config equals the JSON block", + "pass": true, + "detail": "" + }, + { + "contract": "forge-collab", + "name": "same document types", + "pass": true, + "detail": "5 types on chain, 5 in the JSON" + }, + { + "contract": "forge-collab", + "name": "every documentSchema equals the JSON (ids substituted)", + "pass": true, + "detail": "sha256 60e7d65d578d == 60e7d65d578d" + }, + { + "contract": "forge-collab", + "name": "schemaDefs equal the JSON", + "pass": true, + "detail": "" + }, + { + "contract": "forge-collab", + "name": "recorded schemaHash is the substituted JSON's", + "pass": true, + "detail": "98711a791999" + }, + { + "contract": "forge-community", + "name": "registered on chain", + "pass": true, + "detail": "68HtWxTtbgFjHNnkBXKP72J3ikxdieT2EY4bsuGz7Zpp version 1" + }, + { + "contract": "forge-community", + "name": "owner is the deployer and version is 1 (recorded)", + "pass": true, + "detail": "CCFcNqhKo9H3Jo9TRdeBBhD1mpfehWmTYd6a4hpfqdeX v1" + }, + { + "contract": "forge-community", + "name": "config $formatVersion 2", + "pass": true, + "detail": "2" + }, + { + "contract": "forge-community", + "name": "readonly false", + "pass": true, + "detail": "false" + }, + { + "contract": "forge-community", + "name": "canBeDeleted false, keepsHistory false (no moderation)", + "pass": true, + "detail": "{\"canBeDeleted\":false,\"keepsHistory\":false}" + }, + { + "contract": "forge-community", + "name": "config keys beyond the JSON block are unset defaults (null)", + "pass": true, + "detail": "{\"requiresIdentityEncryptionBoundedKey\":null,\"requiresIdentityDecryptionBoundedKey\":null}" + }, + { + "contract": "forge-community", + "name": "config equals the JSON block", + "pass": true, + "detail": "" + }, + { + "contract": "forge-community", + "name": "same document types", + "pass": true, + "detail": "9 types on chain, 9 in the JSON" + }, + { + "contract": "forge-community", + "name": "every documentSchema equals the JSON (ids substituted)", + "pass": true, + "detail": "sha256 12e2e49f1628 == 12e2e49f1628" + }, + { + "contract": "forge-community", + "name": "schemaDefs equal the JSON", + "pass": true, + "detail": "" + }, + { + "contract": "forge-community", + "name": "recorded schemaHash is the substituted JSON's", + "pass": true, + "detail": "833610faa0c6" + }, + { + "contract": "forge-meta", + "name": "registered on chain", + "pass": true, + "detail": "8qj74sQtGWq5Rwf5ihgNibD2tkwX61JLqvbkN2mhgcYT version 3" + }, + { + "contract": "forge-meta", + "name": "owner is the deployer and version is 3 (recorded)", + "pass": true, + "detail": "CCFcNqhKo9H3Jo9TRdeBBhD1mpfehWmTYd6a4hpfqdeX v3" + }, + { + "contract": "forge-meta", + "name": "config $formatVersion 2", + "pass": true, + "detail": "2" + }, + { + "contract": "forge-meta", + "name": "readonly false", + "pass": true, + "detail": "false" + }, + { + "contract": "forge-meta", + "name": "canBeDeleted false, keepsHistory false (no moderation)", + "pass": true, + "detail": "{\"canBeDeleted\":false,\"keepsHistory\":false}" + }, + { + "contract": "forge-meta", + "name": "config keys beyond the JSON block are unset defaults (null)", + "pass": true, + "detail": "{\"requiresIdentityEncryptionBoundedKey\":null,\"requiresIdentityDecryptionBoundedKey\":null}" + }, + { + "contract": "forge-meta", + "name": "config equals the JSON block", + "pass": true, + "detail": "" + }, + { + "contract": "forge-meta", + "name": "same document types", + "pass": true, + "detail": "10 types on chain, 10 in the JSON" + }, + { + "contract": "forge-meta", + "name": "every documentSchema equals the JSON (ids substituted)", + "pass": true, + "detail": "sha256 717b02be82be == 717b02be82be" + }, + { + "contract": "forge-meta", + "name": "schemaDefs equal the JSON", + "pass": true, + "detail": "" + }, + { + "contract": "forge-meta", + "name": "recorded schemaHash is the substituted JSON's", + "pass": true, + "detail": "37773c7b0ea5" + } + ] +} diff --git a/forge-contracts/evidence/testnet/rehearsal-scratch-record.json b/forge-contracts/evidence/testnet/rehearsal-scratch-record.json index 5cd60dc65..80fbd5e94 100644 --- a/forge-contracts/evidence/testnet/rehearsal-scratch-record.json +++ b/forge-contracts/evidence/testnet/rehearsal-scratch-record.json @@ -110,6 +110,21 @@ "gitCommitPushed": true, "status": "updated", "at": "2026-10-26T18:09:54.434Z" + }, + { + "contractNonce": "3", + "kind": "dataContractUpdate", + "key": "forgeMeta", + "contractId": "8qj74sQtGWq5Rwf5ihgNibD2tkwX61JLqvbkN2mhgcYT", + "version": 3, + "schemaHash": "37773c7b0ea5fdd24dcd38ca84f4892ce49d179d3ba952ea3ce128e5bdfd194c", + "previousSchemaHash": "7c46bde00abab29a095bcce067f674f25e68b8dce4b3502bda9dec42bd3394dc", + "sourceSha256": "e32b1ff316dd4821a5161bf6ba2b22ae195d7dddbb039643ab07542239015448", + "transitionSha256": "4a928eb3d47cfc62440c1cc3a5e27d8d90ea72377a6b58ba1dc1c84d4795b9d9", + "gitCommit": "c49f8966f7e7f21dfc6cd9a66a82a10fadc44f5a", + "gitCommitPushed": false, + "status": "updated", + "at": "2026-10-27T22:15:36.844Z" } ], "forgeCollab": { @@ -176,7 +191,7 @@ "status": "registered", "sizeBytes": 6976, "roomBytes": 13504, - "schemaHash": "7c46bde00abab29a095bcce067f674f25e68b8dce4b3502bda9dec42bd3394dc", + "schemaHash": "37773c7b0ea5fdd24dcd38ca84f4892ce49d179d3ba952ea3ce128e5bdfd194c", "registeredSchemaHash": "3d5d945028fd3aae71971ddac686f415a563e89c26ec9ab100716c9642a6d8ee", "documentsHash": "aa8ad5d399810339528a33ba7bc1915f9c587ab00689b2a0a279272ce9b1a8dc", "sourceFile": "forge-contracts/contracts/mainnet/forge-meta.json", @@ -212,9 +227,27 @@ "costCredits": "39040977570", "costDash": 0.3904097757, "updatedAt": "2026-10-26T18:10:00.225Z" + }, + { + "version": 3, + "identityNonce": "3", + "sizeBytes": 10913, + "transitionSha256": "4a928eb3d47cfc62440c1cc3a5e27d8d90ea72377a6b58ba1dc1c84d4795b9d9", + "schemaHash": "37773c7b0ea5fdd24dcd38ca84f4892ce49d179d3ba952ea3ce128e5bdfd194c", + "previousSchemaHash": "7c46bde00abab29a095bcce067f674f25e68b8dce4b3502bda9dec42bd3394dc", + "sourceFile": "forge-contracts/contracts/mainnet/forge-meta.json", + "sourceSha256": "e32b1ff316dd4821a5161bf6ba2b22ae195d7dddbb039643ab07542239015448", + "gitCommit": "c49f8966f7e7f21dfc6cd9a66a82a10fadc44f5a", + "gitCommitPushed": false, + "balanceBefore": "58479972440", + "status": "updated", + "costCredits": "46117473070", + "costDash": 0.4611747307, + "confirmedAt": "2026-10-27T22:16:32.602Z", + "costNote": "balance delta since the recorded pre-broadcast balance" } ], - "version": 2 + "version": 3 }, "contractGroupId": "28WdQQm2kF5PH3oQonjJSQUsd9QuXbSDATuFiAKdQqm4", "contractGroup": { diff --git a/forge-contracts/evidence/testnet/update-meta-v3.sha256 b/forge-contracts/evidence/testnet/update-meta-v3.sha256 new file mode 100644 index 000000000..ec2ddac8b --- /dev/null +++ b/forge-contracts/evidence/testnet/update-meta-v3.sha256 @@ -0,0 +1,4 @@ +c280e9d4ecbcba0647c882f99ae39dbbe833e7225aa4b7d07f2c815f3e51b9a5 forge-core.json +bb7735b8d191d506edf392c3536b1ef706281fa8b50d912c9223a79c9fc1b324 forge-collab.json +77a822bda29f70a45cab0b08dc4902ce572df8a05a8e1205457330a9e19167d1 forge-community.json +e32b1ff316dd4821a5161bf6ba2b22ae195d7dddbb039643ab07542239015448 forge-meta.json diff --git a/forge-contracts/schema/build.py b/forge-contracts/schema/build.py index a7fc4abb7..9a9c73503 100644 --- a/forge-contracts/schema/build.py +++ b/forge-contracts/schema/build.py @@ -155,12 +155,18 @@ # (META_TYPES): on a registered network it ships as `deploy-v2.mjs --update meta`, on one not yet # registered it is part of the registration set. passkey_vault=True, # vaultEntry: a passkey-sealed key bundle per (owner, credential id) + # ---- UPDATE-3 (boards, docs/design/boards.md §3): two new document types only, as UPDATE-2. Four-contract + # set only (`layout_meta`), moved to forge-meta by META_TYPES; `deploy-v2.mjs --update meta` on a + # registered network (forge-meta v3 on testnet), part of the registration set elsewhere. + boards=True, # board (a board's definition) and card (a member's placement of one item) ) # The UPDATE-1 items: every one off is the registered v1 set (registered/*.v1.json). UPDATE1_FLAGS = ('release_target_oid', 'config_moved_to', 'pack_mirror', 'transition_closed_by_pr', 'profile_key_proofs', 'profile_bot', 'author_retarget', 'policy_code_owners', 'repo_ban') # The UPDATE-2 items: added after UPDATE-1, so the registered v1 set has them off too (stale_registered). UPDATE2_FLAGS = ('passkey_vault',) +# The UPDATE-3 items: added after UPDATE-2, off in the registered v1 set too (stale_registered). +UPDATE3_FLAGS = ('boards',) # Each production network's registration (CONT-03): the committed set it registered, and the flags added after # it. `contracts/registered//.v1.json` is a byte copy of what that network registered # (`freeze-registered.mjs` writes it at the registration commit, P4) and the build with the `since` flags off @@ -171,7 +177,7 @@ # registration; a flag that was on and is later turned off cannot be expressed (--check fails loudly). NETWORK_REGISTRATIONS = { # testnet (dash-testnet-51), Platform 5.0.0-rc.8, 2026-10-26: forge-core D2ZLdgghZTKGpES35a3KVDp5necSfZqqRHLSknjRPAV9 - 'testnet': {'set': 'mainnet', 'since': ('passkey_vault',)}, + 'testnet': {'set': 'mainnet', 'since': ('passkey_vault', 'boards')}, } # ---- Mainnet-only (a fresh registration may add them; an update never can: rules, references and # required fields on existing types are frozen, forge-v2.md §9). Off in every devnet build; the mainnet @@ -308,7 +314,7 @@ GRANT_TTL_MS = 90 * 24 * 3600 * 1000 # D44: the types forge-meta takes, from the contract that holds them in the three-contract set META_TYPES = {'forge-collab': ('repoKey', 'ban'), 'forge-core': ('label', 'topic', 'packMirror'), - 'forge-community': ('profile', 'follow', 'vaultEntry')} + 'forge-community': ('profile', 'follow', 'vaultEntry', 'board', 'card')} # The riders: independent of the RC2 items (other types and properties), so variants.py turns # each off only with every RC2 item on, the largest build. RIDER_FLAGS = ('close_reason', 'review_hunk') @@ -1016,6 +1022,87 @@ def writer_leaf(t): "required": ["$createdAt", "$updatedAt", "credentialId", "recipientKey", "version", "authKeyId", "enc", "sealed"], "additionalProperties": False} + # ======================= UPDATE-3 (boards, docs/design/boards.md §3) ======================= + # Two new document types with their own indexes, so protocol 14 lets an update add them, as UPDATE-2. + # Built with the four-contract layout only and moved to forge-meta (META_TYPES): their references name + # forge-core (the member gate) and forge-collab (the item) by id, which only a later contract may. + # Both are mutable and never deleted, one document per (member, board[, item]): a member's later write + # replaces their own (a replace costs a fraction of a create) and readers take the newest across + # members. A delete would silently bring back an older member's document, which no poll of + # `$updatedAt` sees, and a removed member could still delete theirs, so `state` 2 is the delete. Every + # index key and both timestamps are required: an unrequired `$updatedAt` is never recorded, and a unique + # index holds no document missing a key part. The gate is label's: a maintainer of the home repo, or a + # writer whose role is the claimed `r`; a `deletableDocument` found by `findBy` is asked again on every + # replace (book contract-keywords/owner-refers-to.md "On replace"), so a removed member cannot touch + # their old documents and a role change holds from the next write. No `ownerRefersTo` operand can be + # added by a later update (§9): only the home repo's members write, and a card always names an issue or + # a PR. `enc` is inlined in both: forge-meta's `$defs.enc` (label's, 1,536 B) is too small for a board. + if up['boards'] and f['layout_meta']: + if not f['member_roles']: # (not in NEEDS: the three-contract builds have `boards` on and no forge-meta) + sys.exit('boards needs member_roles: the writer leaf proves `r` against writer.role') + u32 = {"type": "integer", "minimum": 0, "maximum": 4294967295} + key = {"type": "integer", "minimum": 1, "maximum": 4294967295} + gate = {"anyOf": [find_leaf("maintainer", CORE), dict(find_leaf("writer", CORE), where={"role": "r"})]} + # A board's definition, one per (home repo, key, member): `name` and `spec` (§2, JSON, `v: 1`) in a + # public repo, sealed together in `enc` in a private one (bound to `u32(key)`, private-repos.md §4.4). + # `state` 0 open, 1 closed, 2 deleted. Maintainers and role-1 writers define boards (r = 1). + md['board'] = { + "type": "object", "documentsMutable": True, "canBeDeleted": False, + "ownerRefersTo": copy.deepcopy(gate), + "properties": { + "repoId": {"$ref": "#/$defs/id", "position": 0}, + "key": dict(key, position=1), + "name": {"type": "string", "minLength": 1, "maxLength": 63, "maxBytes": 252, "pattern": TITLE, "position": 2}, + "spec": {"type": "string", "minLength": 1, "maxLength": 4096, "maxBytes": 4096, "position": 3}, + "state": {"type": "integer", "minimum": 0, "maximum": 2, "position": 4}, + "enc": {"type": "array", "byteArray": True, "minItems": 29, "maxItems": 5120, "position": 5}, + "epoch": dict(u32, position=6), + "r": {"type": "integer", "minimum": 1, "maximum": 1, "position": 7}}, + "immutable": ["repoId", "key"], + "indices": [ + # One definition per (repo, board, member); the repoId prefix lists a repo's boards + {"name": "byKey", "properties": [{"repoId": "asc"}, {"key": "asc"}, {"$ownerId": "asc"}], "unique": True}], + "required": ["$createdAt", "$updatedAt", "repoId", "key", "state", "r"], + "additionalProperties": False, + "dependentRequired": {"enc": ["epoch"]}, + "propertyConstraints": { + "noPlain": {"anyOf": [{"absent": "enc"}, {"allOf": [{"absent": "name"}, {"absent": "spec"}]}]}, + "hasName": {"anyOf": [{"present": "enc"}, {"allOf": [{"present": "name"}, {"present": "spec"}]}]}}} + # A member's placement and field values for one item on one board: `col` (0 = none), `rank` (§2.6, + # base-62, never ending in `0`) and `f` (JSON field values) in a public repo, sealed in `enc` in a + # private one (bound to `u32(board) ‖ item`). `item` is any repository's issue or PR (no `where`). + # `state` 0 active, 1 archived, 2 removed, plaintext everywhere. Maintainers, writers and triage + # place cards (r 1-2). + md['card'] = { + "type": "object", "documentsMutable": True, "canBeDeleted": False, + "ownerRefersTo": copy.deepcopy(gate), + "properties": { + "repoId": {"$ref": "#/$defs/id", "position": 0}, + "board": dict(key, position=1), + "item": ident(refersTo={"anyOf": [ + {"type": "permanentDocument", "contractId": COLLAB, "documentType": "issue"}, + {"type": "permanentDocument", "contractId": COLLAB, "documentType": "patch"}]}, position=2), + "col": {"type": "integer", "minimum": 0, "maximum": 255, "position": 3}, + "rank": {"type": "string", "minLength": 1, "maxLength": 63, "pattern": "^[0-9A-Za-z]*[1-9A-Za-z]$", + "position": 4}, + "f": {"type": "string", "minLength": 1, "maxLength": 2048, "maxBytes": 2048, "position": 5}, + "state": {"type": "integer", "minimum": 0, "maximum": 2, "position": 6}, + "enc": {"type": "array", "byteArray": True, "minItems": 29, "maxItems": 2560, "position": 7}, + "epoch": dict(u32, position=8), + "r": {"type": "integer", "minimum": 1, "maximum": 2, "position": 9}}, + "immutable": ["repoId", "board", "item"], + "indices": [ + # One card per (item, board, member); the item prefix answers "which boards is this on" + {"name": "onItem", "properties": [{"item": "asc"}, {"repoId": "asc"}, {"board": "asc"}, {"$ownerId": "asc"}], + "unique": True}, + # Load a board, and poll it for what changed since a time + {"name": "recent", "properties": [{"repoId": "asc"}, {"board": "asc"}, {"$updatedAt": "asc"}]}], + "required": ["$createdAt", "$updatedAt", "repoId", "board", "item", "state", "r"], + "additionalProperties": False, + "dependentRequired": {"enc": ["epoch"]}, + "propertyConstraints": { + "noPlain": {"anyOf": [{"absent": "enc"}, {"allOf": [{"absent": "col"}, {"absent": "rank"}, {"absent": "f"}]}]}}} + # ======================= mixed visibility (DESIGN rev 4.1 §8.3) ======================= # A fresh registration only: each adds a rule, a reference or a required field to a type that # exists, which no update can (§9). Row numbers are DESIGN §8.2's; forge-v2.md §9.1 has each. @@ -1342,6 +1429,9 @@ def public_const(t, stamp_rule=None): for t in (ev_home['event'], ev_home['milestone'], cd['label']): t.setdefault('propertyConstraints', {})['rClaim'] = {"in": ["r", [1, 2]]} md['checkRun']['propertyConstraints']['rClaim'] = {"equal": ["r", 1]} + if 'board' in md: # UPDATE-3: role-1 writers define boards, triage places cards too + md['board']['propertyConstraints']['rClaim'] = {"equal": ["r", 1]} + md['card']['propertyConstraints']['rClaim'] = {"in": ["r", [1, 2]]} rk_home['repoKey'].setdefault('propertyConstraints', {})['mrClaim'] = {"in": ["mr", [1, 2, 3]]} # The push class is bounded by B1's own rules (botGrant, botPack, botChunk); a build without B1 # bounds each claim by its schema range instead @@ -1585,11 +1675,11 @@ def stale_registered(registered_root, registrations): or an entry with no directory, is stale: what a network registered is frozen in the same commit that names it.""" stale = [] - v1 = build(flags_from(','.join(UPDATE1_FLAGS + UPDATE2_FLAGS))) + v1 = build(flags_from(','.join(UPDATE1_FLAGS + UPDATE2_FLAGS + UPDATE3_FLAGS))) for n in NAMES: p = os.path.join(registered_root, f'{n}.v1.json') if not os.path.exists(p) or open(p).read() != dumps(v1[n]): - stale.append((p, 'is not the build with every UPDATE-1 and UPDATE-2 flag off')) + stale.append((p, 'is not the build with every UPDATE-1, UPDATE-2 and UPDATE-3 flag off')) dirs = sorted(d for d in os.listdir(registered_root) if os.path.isdir(os.path.join(registered_root, d))) \ if os.path.isdir(registered_root) else [] for d in dirs: diff --git a/forge-contracts/schema/vectors.py b/forge-contracts/schema/vectors.py index 0237f0cd8..48a63255a 100644 --- a/forge-contracts/schema/vectors.py +++ b/forge-contracts/schema/vectors.py @@ -931,6 +931,101 @@ def sealed_release(name): else: index('U2', 'no vaultEntry type', 'vaultEntry', None, False) +# ---------------- UPDATE-3: boards (docs/design/boards.md §3) ---------------- +# The shapes, the plaintext/sealed rules and the frozen keys. The member gate (a maintainer, or a writer of +# the claimed role), its re-check on a replace and `card.item` naming an issue or a PR are references, judged +# by the offline chain (scripts/lib/offline-chain.test.mjs); no live suite case covers them yet. +CONTRACT_OF.update(board='forge-community', card='forge-community') +if F['boards'] and F['layout_meta']: # (build.py builds them with the four-contract layout only) + BASE['board'] = {"repoId": i(1), "key": 1, "name": "Roadmap", "spec": '{"v":1,"cols":[{"id":1,"name":"Todo"}]}', + "state": 0, "r": 1} + BASE['card'] = {"repoId": i(1), "board": 1, "item": i(2), "col": 1, "rank": "V", "f": '{"1":3}', "state": 0, "r": 1} + for _t in ('board', 'card'): + ok('base', f'{_t} ok', _t) + # board + ok('U3', 'a sealed board', 'board', name=DROP, spec=DROP, **SEALED) + ok('U3', 'a closed board', 'board', state=1) + ok('U3', 'a deleted board', 'board', state=2) + no('U3', 'a board in state 3', 'board', 'maximum', state=3) + ok('U3', 'board key 4294967295', 'board', key=4294967295) + no('U3', 'board key 0', 'board', 'minimum', key=0) + no('U3', 'board key 4294967296', 'board', 'maximum', key=4294967296) + no('U3', 'a board claiming role 2 (triage defines no board)', 'board', 'maximum', r=2) + no('U3', 'a board claiming role 0', 'board', 'minimum', r=0) + no('U3', 'a sealed board with a plaintext name', 'board', 'noPlain', spec=DROP, **SEALED) + no('U3', 'a sealed board with a plaintext definition', 'board', 'noPlain', name=DROP, **SEALED) + no('U3', 'a plaintext board without a name', 'board', 'hasName', name=DROP) + no('U3', 'a plaintext board without a definition', 'board', 'hasName', spec=DROP) + no('U3', 'a sealed board without its epoch', 'board', 'required', name=DROP, spec=DROP, enc=b(5, 61)) + ok('U3', 'a board name of 63 four-byte characters', 'board', name='\U0001F600' * 63) + no('U3', 'a board name of 64 characters', 'board', 'maxLength', name='x' * 64) + no('U3', 'an empty board name', 'board', 'minLength', name='') + no('U3', 'a board name of spaces', 'board', 'pattern', name=' ') + no('U3', 'a board name with a control character', 'board', 'pattern', name='a\nb') + ok('U3', 'a definition of 4096 bytes', 'board', spec='x' * 4096) + no('U3', 'a definition of 4097 characters', 'board', 'maxLength', spec='x' * 4097) + no('U3', 'a definition over 4096 bytes', 'board', 'maxBytes', spec='é' * 2049) + ok('U3', 'a sealed board of 5120 bytes', 'board', name=DROP, spec=DROP, enc=b(5, 5120), epoch=0) + no('U3', 'a board enc of 28 bytes', 'board', 'minItems', name=DROP, spec=DROP, enc=b(5, 28), epoch=0) + no('U3', 'a board enc over the 5120-byte field limit', 'board', '10417', name=DROP, spec=DROP, enc=b(5, 5121), epoch=0) + for _p in ('repoId', 'key', 'state', 'r'): + no('U3', f'a board without {_p}', 'board', 'required', **{_p: DROP}) + no('U3', 'a board with another property', 'board', 'additionalProperties', color='#00ff00') + _STORED = doc('board') + replace('U3', 'a board renamed, redefined and closed', 'board', _STORED, None, name='Plan', spec='{"v":1}', state=1) + replace('U3', 'a board deleted (state 2)', 'board', _STORED, None, state=2) + replace('U3', 'board key changed (immutable)', 'board', _STORED, '40128', key=2) + replace('U3', 'board repoId changed (immutable)', 'board', _STORED, '40128', repoId=i(3)) + index('U3', "one definition per repo, board and member; a repo's boards by its prefix", 'board', 'byKey', True, + properties=['repoId', 'key', '$ownerId'], unique=True) + # card + ok('U3', 'a sealed card', 'card', col=DROP, rank=DROP, f=DROP, **SEALED) + ok('U3', 'a card with no column, rank or fields', 'card', col=DROP, rank=DROP, f=DROP) + ok('U3', 'an archived card', 'card', state=1) + ok('U3', 'a removed card', 'card', state=2) + no('U3', 'a card in state 3', 'card', 'maximum', state=3) + ok('U3', 'a triage card (role 2)', 'card', r=2) + no('U3', 'a card claiming role 3 (a reader places nothing)', 'card', 'maximum', r=3) + no('U3', 'a card claiming role 0', 'card', 'minimum', r=0) + no('U3', 'a sealed card with a plaintext column', 'card', 'noPlain', rank=DROP, f=DROP, **SEALED) + no('U3', 'a sealed card with a plaintext rank', 'card', 'noPlain', col=DROP, f=DROP, **SEALED) + no('U3', 'a sealed card with plaintext field values', 'card', 'noPlain', col=DROP, rank=DROP, **SEALED) + no('U3', 'a sealed card without its epoch', 'card', 'required', col=DROP, rank=DROP, f=DROP, enc=b(5, 61)) + ok('U3', 'column 255', 'card', col=255) + no('U3', 'column 256', 'card', 'maximum', col=256) + no('U3', 'column -1', 'card', 'minimum', col=-1) + no('U3', 'card board key 0', 'card', 'minimum', board=0) + ok('U3', 'a rank of 63 digits', 'card', rank='z' * 63) + ok('U3', 'a rank of one digit 1', 'card', rank='1') + no('U3', 'a rank of 64 digits', 'card', 'maxLength', rank='z' * 64) + no('U3', 'an empty rank', 'card', 'minLength', rank='') + no('U3', 'a rank ending in 0', 'card', 'pattern', rank='V0') + no('U3', 'a rank of 0 alone', 'card', 'pattern', rank='0') + no('U3', 'a rank outside the 62 digits', 'card', 'pattern', rank='a-b') + ok('U3', 'field values of 2048 bytes', 'card', f='x' * 2048) + no('U3', 'field values of 2049 characters', 'card', 'maxLength', f='x' * 2049) + no('U3', 'field values over 2048 bytes', 'card', 'maxBytes', f='é' * 1025) + ok('U3', 'a sealed card of 2560 bytes', 'card', col=DROP, rank=DROP, f=DROP, enc=b(5, 2560), epoch=0) + no('U3', 'a card enc of 28 bytes', 'card', 'minItems', col=DROP, rank=DROP, f=DROP, enc=b(5, 28), epoch=0) + no('U3', 'a card enc of 2561 bytes', 'card', 'maxItems', col=DROP, rank=DROP, f=DROP, enc=b(5, 2561), epoch=0) + for _p in ('repoId', 'board', 'item', 'state', 'r'): + no('U3', f'a card without {_p}', 'card', 'required', **{_p: DROP}) + no('U3', 'a card with another property', 'card', 'additionalProperties', note='hi') + _STORED = doc('card') + replace('U3', 'a card moved and re-ranked', 'card', _STORED, None, col=2, rank='Vk') + replace('U3', 'a card archived', 'card', _STORED, None, state=1) + replace('U3', 'a card removed', 'card', _STORED, None, state=2) + replace('U3', 'card item changed (immutable)', 'card', _STORED, '40128', item=i(3)) + replace('U3', 'card board changed (immutable)', 'card', _STORED, '40128', board=2) + replace('U3', 'card repoId changed (immutable)', 'card', _STORED, '40128', repoId=i(3)) + index('U3', 'one card per item, board and member; the boards an item is on by its prefix', 'card', 'onItem', True, + properties=['item', 'repoId', 'board', '$ownerId'], unique=True) + index('U3', "a board's cards, changed since a time", 'card', 'recent', True, + properties=['repoId', 'board', '$updatedAt'], unique=False) +else: + for _t in ('board', 'card'): + index('U3', f'no {_t} type', _t, None, False) + # ---------------- the other mainnet-only rules (forge-v2.md §9.1) ---------------- if F['mainnet_release_target']: no('MN', 'a public publish without targetOid', 'release', 'targetOnPublish', targetOid=DROP) @@ -1159,7 +1254,9 @@ def sealed_release(name): UPDATE_GUARDS = {('transition', 'k_kinds'), ('checkRun', 'rClaim'), ('event', 'rClaim'), ('milestone', 'rClaim'), ('label', 'rClaim'), ('repoKey', 'mrClaim'), # a build without B1 (variants only): the push class's claims - ('refUpdate', 'rClaim'), ('packManifest', 'rClaim'), ('chunk', 'rClaim')} + ('refUpdate', 'rClaim'), ('packManifest', 'rClaim'), ('chunk', 'rClaim'), + # UPDATE-3: role-1 writers define boards, triage places cards too + ('board', 'rClaim'), ('card', 'rClaim')} def uncovered(): @@ -1184,6 +1281,8 @@ def uncovered(): ('label', 'r', {'maximum': 4}, 3, 'rClaim'), ('checkRun', 'r', {'maximum': 4}, 2, 'rClaim'), ('repoKey', 'mr', {'maximum': 4}, 4, 'mrClaim')] +if 'board' in BASE: + GUARD_LOOSENINGS += [('board', 'r', {'maximum': 4}, 2, 'rClaim'), ('card', 'r', {'maximum': 4}, 3, 'rClaim')] def guard_check(out): diff --git a/forge-contracts/scripts/deploy-v2.mjs b/forge-contracts/scripts/deploy-v2.mjs index e06fcb7f5..0d7e59d88 100644 --- a/forge-contracts/scripts/deploy-v2.mjs +++ b/forge-contracts/scripts/deploy-v2.mjs @@ -100,6 +100,7 @@ // // forge-meta (DESIGN rev 4.1 D44): when holds forge-meta.json it is registered fourth, after // forge-community, like the others: its schema names forge-core's id (FORGE_CORE_CONTRACT_ID), and +// with boards (UPDATE-3) forge-collab's (FORGE_COLLAB_CONTRACT_ID: a card names an issue or a PR), and // its create transition enrols it in the group. `--only meta` registers it alone against the // recorded forge-core and group (an earlier run that registered the three). // @@ -128,6 +129,8 @@ // community do the same for forge-collab and forge-community (the recorded ids replace their // placeholders), and --update all updates the three in registration order (UPDATE-1, roadmap D4; // check each with contract-validate --expect-update registered/.v1.json first). +// --update meta updates forge-meta alone, with every recorded id substituted (UPDATE-2's vaultEntry +// names none; UPDATE-3's board and card name forge-core and forge-collab). // // --force-new without --only does the same for the set: when the recorded forge-core was // registered from a different schema (a change such as a new `required` system field, which the @@ -316,6 +319,11 @@ function selfTest(dir = DEFAULT_CONTRACTS_DIR, log = defaultLog) { if (!schemaText('forge-community', dir).includes(placeholderFor('forge-collab'))) { throw new Error('forge-community names no FORGE_COLLAB_CONTRACT_ID: its events would not refer to this forge-collab'); } + // UPDATE-3: a card names any repository's issue or PR, so a forge-meta with cards names forge-collab + if (dependents.includes(META_CONTRACT) && JSON.parse(schemaText(META_CONTRACT.schemaName, dir)).documentSchemas.card + && !schemaText(META_CONTRACT.schemaName, dir).includes(placeholderFor('forge-collab'))) { + throw new Error('forge-meta names no FORGE_COLLAB_CONTRACT_ID: its cards would not refer to this forge-collab'); + } const ids = { [PLACEHOLDER]: want.contract }; for (const { schemaName } of dependents) { const raw = schemaText(schemaName, dir); @@ -1521,7 +1529,7 @@ async function deploy(argv, injected, locks) { return id; } - // --update : an in-place DataContractUpdate of each recorded contract + // --update : an in-place DataContractUpdate of each recorded contract // to its current schema, as the next version (in registration order: core, collab, community). // Returns the step to report; resumable (see the header). async function updateContract({ key, schemaName, substitutions }) { @@ -1529,8 +1537,16 @@ async function deploy(argv, injected, locks) { if (!rec?.contractId || rec.status !== 'registered') throw new Error(`--update: no registered ${schemaName} recorded for this network`); const json = load(schemaName, substitutions); const hash = schemaHash(json); - const onChain = await sdk.contracts.fetch(rec.contractId); + let onChain = await sdk.contracts.fetch(rec.contractId); if (!onChain) throw new Error(`--update: ${rec.contractId} is recorded but not on chain`); + // A pending update a node may not show yet: read again before broadcasting it a second time + // (a lagging node proves the version before it; a rebroadcast would be refused, and the + // record's pre-broadcast balance overwritten) + for (let i = 0; rec.pendingUpdate && Number(onChain.version) < rec.pendingUpdate.version && i < (injected.settleTries ?? 10); i++) { + await new Promise((r) => setTimeout(r, injected.settleMs ?? 2000)); + sdk.wasm?.removeCachedContract?.(onChain.id); + onChain = (await sdk.contracts.fetch(rec.contractId)) ?? onChain; + } const chainVersion = Number(onChain.version); // Close an update out: the version and schema it took the contract to, and what it cost. const complete = (pending, cost, extra) => { @@ -1590,7 +1606,14 @@ async function deploy(argv, injected, locks) { const after = await settledBalance(before); // The SDK cached the contract fetched above: drop it, so the check reads the new version sdk.wasm?.removeCachedContract?.(onChain.id); - const fetched = await sdk.contracts.fetch(rec.contractId); + let fetched = await sdk.contracts.fetch(rec.contractId); + // (a node that has not applied the block yet still proves the old version: read again, as the + // creates do; testnet's scratch update to forge-meta v3 met one on 2026-10-27) + for (let i = 0; (!fetched || Number(fetched.version) < version) && i < (injected.settleTries ?? 10); i++) { + await new Promise((r) => setTimeout(r, injected.settleMs ?? 2000)); + sdk.wasm?.removeCachedContract?.(onChain.id); + fetched = await sdk.contracts.fetch(rec.contractId); + } if (!fetched || Number(fetched.version) !== version) throw new Error(`${key}: update broadcast but the chain shows version ${fetched ? fetched.version : 'none'}`); complete(rec.pendingUpdate, before - after, { updatedAt: stamp() }); say(`${key}: updated to version ${version}; cost ${(Number(before - after) / CREDITS_PER_DASH).toFixed(6)} DASH`); diff --git a/forge-contracts/scripts/deploy-v2.test.mjs b/forge-contracts/scripts/deploy-v2.test.mjs index 2e32ff40e..298bb3a31 100644 --- a/forge-contracts/scripts/deploy-v2.test.mjs +++ b/forge-contracts/scripts/deploy-v2.test.mjs @@ -530,6 +530,95 @@ test('--update core on a production record: the contract-nonce ledger entry, reg await assert.rejects(t.run(t.prod('--update', 'core')), /differ from git HEAD/); }); +test('--update meta names the recorded forge-core and forge-collab (UPDATE-3: card.item refers to forge-collab)', async () => { + const t = setup(); + await t.run(t.prod()); + const { forgeCore, forgeCollab, forgeMeta } = t.read().v2; + // pretend the chain holds an older forge-meta than the committed file (testnet's v2, before boards) + const tampered = t.read(); + tampered.v2.forgeMeta.schemaHash = '0'.repeat(64); + writeFileSync(t.testnetFile, JSON.stringify(tampered, null, 2)); + await t.run(t.prod('--update', 'meta')); + const rec = t.read(); + assert.equal(rec.v2.forgeMeta.version, 2); + assert.equal(rec.v2.forgeMeta.schemaHash, forgeMeta.schemaHash); + // only forge-meta was updated + assert.deepEqual(rec.v2.nonceLedger.filter((e) => e.kind === 'dataContractUpdate').map((e) => e.key), ['forgeMeta']); + const sent = t.fake.state.contracts.get(forgeMeta.contractId).json; + assert.equal(sent.version, 2); + assert.ok(!JSON.stringify(sent).includes('_CONTRACT_ID'), 'no placeholder left in the update'); + const { board, card } = sent.documentSchemas; + for (const leaf of [...board.ownerRefersTo.anyOf, ...card.ownerRefersTo.anyOf]) assert.equal(leaf.contractId, forgeCore.contractId, leaf.documentType); + assert.deepEqual(card.properties.item.refersTo.anyOf.map((l) => [l.documentType, l.contractId]), + [['issue', forgeCollab.contractId], ['patch', forgeCollab.contractId]]); +}); + +test('--update reads the version again while the node still proves the one before (testnet scratch, 2026-10-27)', async () => { + const lagging = (t, staleReads) => { + let stale = 0; + class Lagging extends t.fake.evo.EvoSDK { + constructor(options) { + super(options); + const { broadcastAndWait } = this.stateTransitions; + const { fetch } = this.contracts; + this.stateTransitions.broadcastAndWait = async (st) => { + try { + await broadcastAndWait(st); + } finally { + stale = staleReads; + } + }; + this.contracts.fetch = async (id) => { + const c = await fetch(id); + if (stale === 0 || !c) return c; + stale -= 1; + return { ...c, version: c.version - 1 }; + }; + } + } + return { ...t.fake.evo, EvoSDK: Lagging }; + }; + const t = setup(); + await t.run(t.prod()); + const tampered = t.read(); + tampered.v2.forgeMeta.schemaHash = '0'.repeat(64); + writeFileSync(t.testnetFile, JSON.stringify(tampered, null, 2)); + // two stale reads, three tries: the update completes + await t.run(t.prod('--update', 'meta'), { evo: lagging(t, 2), settleTries: 3 }); + assert.equal(t.read().v2.forgeMeta.version, 2); + assert.equal(t.read().v2.forgeMeta.pendingUpdate, undefined); + // a node that never catches up within the tries: the run stops with the update pending (a rerun settles it) + const again = setup(); + await again.run(again.prod()); + const old = again.read(); + old.v2.forgeMeta.schemaHash = '0'.repeat(64); + writeFileSync(again.testnetFile, JSON.stringify(old, null, 2)); + await assert.rejects(again.run(again.prod('--update', 'meta'), { evo: lagging(again, 5), settleTries: 2 }), /update broadcast but the chain shows version 1/); + const pending = again.read().v2.forgeMeta.pendingUpdate; + assert.equal(pending.version, 2); + // the rerun meets a node that still lags: it reads again rather than broadcast a second time + const broadcasts = again.fake.broadcasts; + class StillLagging extends again.fake.evo.EvoSDK { + constructor(options) { + super(options); + const { fetch } = this.contracts; + let stale = 2; + this.contracts.fetch = async (id) => { + const c = await fetch(id); + if (stale === 0 || !c) return c; + stale -= 1; + return { ...c, version: c.version - 1 }; + }; + } + } + await again.run(again.prod('--update', 'meta'), { evo: { ...again.fake.evo, EvoSDK: StillLagging }, settleTries: 3 }); + assert.equal(again.fake.broadcasts, broadcasts, 'no second broadcast'); + const done = again.read().v2.forgeMeta; + assert.equal(done.version, 2); + assert.equal(done.pendingUpdate, undefined); + assert.equal(done.updates.at(-1).balanceBefore, pending.balanceBefore); +}); + test('--update refuses a record of the other set', async () => { const t = setup(); await t.run(t.prod()); diff --git a/forge-contracts/scripts/freeze-c1-check.mjs b/forge-contracts/scripts/freeze-c1-check.mjs index 15ffe2175..eb23e0c15 100644 --- a/forge-contracts/scripts/freeze-c1-check.mjs +++ b/forge-contracts/scripts/freeze-c1-check.mjs @@ -3,7 +3,7 @@ // - the registered config is $formatVersion 2, readonly false, no moderation (canBeDeleted false, // no keepsHistory), and equals the JSON's config block (keys the node adds are null); // - each documentSchemas / schemaDefs block equals the JSON's, key for key; -// - owner, version 1, the recorded group. +// - owner, and the version recorded (1, or the last `--update`'s), the recorded group. // // node forge-contracts/scripts/freeze-c1-check.mjs --record --contracts \ // [--network devnet|testnet|mainnet] [--devnet-name sakura] [--report ] @@ -51,7 +51,8 @@ for (const c of SETS) { if (!fetched) { check(c.schemaName, 'registered on chain', false, r.contractId); continue; } const got = fetched.toJSON(); check(c.schemaName, 'registered on chain', true, `${r.contractId} version ${got.version}`); - check(c.schemaName, 'owner is the scratch deployer and version is 1', got.ownerId === r.ownerId && Number(got.version) === 1, `${got.ownerId} v${got.version}`); + const version = Number(r.version ?? 1); + check(c.schemaName, `owner is the deployer and version is ${version} (recorded)`, got.ownerId === r.ownerId && Number(got.version) === version, `${got.ownerId} v${got.version}`); const cfg = got.config ?? {}; check(c.schemaName, 'config $formatVersion 2', String(cfg.$formatVersion) === '2', String(cfg.$formatVersion)); check(c.schemaName, 'readonly false', cfg.readonly === false, String(cfg.readonly)); diff --git a/forge-contracts/scripts/lib/offline-chain.test.mjs b/forge-contracts/scripts/lib/offline-chain.test.mjs index da05b20e7..df6aadf7f 100644 --- a/forge-contracts/scripts/lib/offline-chain.test.mjs +++ b/forge-contracts/scripts/lib/offline-chain.test.mjs @@ -6,7 +6,7 @@ import { join } from 'node:path'; import { test } from 'node:test'; import { OfflineChain } from './offline-chain.mjs'; -import { CONTRACTS, CONTRACT_OF, META_TYPES, ROOT, TRANSITION, VIS, b58encode, contractOn, documentReader, documentWriter, idBytes, membership, shapeOfSet, transition } from './seed-io.mjs'; +import { CONTRACTS, CONTRACT_OF, META_ONLY_TYPES, META_TYPES, ROOT, TRANSITION, VIS, b58encode, contractOn, documentReader, documentWriter, idBytes, membership, shapeOfSet, transition } from './seed-io.mjs'; // The default set's shape, as the seeds read it from the loaded contract. const SHAPE = shapeOfSet({ contracts: CONTRACTS, contractOf: CONTRACT_OF }); @@ -188,8 +188,8 @@ test('the deployment record picks the layout: forge-meta holds the moved types o const three = { core: 'C', collab: 'L', community: 'M' }; const four = { ...three, meta: 'X' }; for (const t of META_TYPES) { - // (vaultEntry, UPDATE-2, is a four-contract type: no home in the three-contract set) - if (t !== 'vaultEntry') { + // (vaultEntry, board and card are four-contract types: no home in the three-contract set) + if (!META_ONLY_TYPES.has(t)) { assert.ok(CONTRACT_OF[t], `${t} has a three-contract home`); assert.equal(contractOn(three, t), CONTRACT_OF[t], t); } @@ -274,6 +274,44 @@ test('a four-contract set: identifier lookups, no topic vis, and asMember with t await assert.rejects(write(person('stranger'), 'issue', asMember(person('stranger'))), refusedWith(40120, 'issue.asMember')); }); +// UPDATE-3 (docs/design/boards.md §3): a board or a card is written by the home repo's members only +// (a maintainer, or a writer of the claimed role: triage places cards and defines no board), the gate is +// asked again on every replace, a card names an issue or a PR, and neither is ever deleted. +test('a four-contract set: boards and cards are the home repo members\', and a card names an issue or a PR', async () => { + const chain = new OfflineChain({ contractsDir: join(ROOT, 'contracts', 'mainnet') }); + const evo = chain.evo(); + const sdk = new evo.EvoSDK(); + const write = documentWriter({ sdk }, evo, { ids: chain.ids }, noReconnect, { shape: shapeOfSet(chain.set), retries: 0 }); + const R = idBytes((await write(OWNER, 'repo', { name: 'r', visibility: VIS })).id.toBase58()); + await write(OWNER, 'maintainer', membership(R, OWNER.id, OWNER.id)); + const item = idBytes((await write(OWNER, 'issue', issue(R, 1))).id.toBase58()); + const board = { repoId: R, key: 7, name: 'Roadmap', spec: '{"v":1}', state: 0, r: 1 }; + const card = { repoId: R, board: 7, item, col: 1, rank: 'V', state: 0, r: 1 }; + const stranger = person('stranger'); + await assert.rejects(write(stranger, 'board', board), refusedWith(40120, 'board.ownerRefersTo')); + await assert.rejects(write(stranger, 'card', card), refusedWith(40120, 'card.ownerRefersTo')); + const defined = await write(OWNER, 'board', board); + await write(OWNER, 'card', card); + // a card names an issue or a PR: the repo's own id is neither + await assert.rejects(write(OWNER, 'card', { ...card, item: R }), refusedWith(40120, 'card.item')); + // triage (role 2) places a card and defines no board + await write(OTHER, 'consent', { repoId: R }); + const row = await write(OWNER, 'writer', { ...membership(R, OWNER.id, OTHER.id), role: 2 }); + await assert.rejects(write(OTHER, 'board', board), refusedWith(40127, 'board.ownerRefersTo')); + const placed = await write(OTHER, 'card', { ...card, r: 2 }); + // a move is a replace of the member's own card, and the gate is asked again on it + const move = (doc, type, owner, data) => { + const d = evo.Document.fromObject({ __meta: { type, contractId: chain.ids.meta, owner: owner.id, id: doc.id.toBase58() }, ...data }); + return sdk.documents.replace({ document: d }); + }; + await move(placed, 'card', OTHER, { ...card, r: 2, col: 2, rank: 'W' }); + await sdk.documents.delete({ document: row }); + await assert.rejects(move(placed, 'card', OTHER, { ...card, r: 2, col: 3 }), refusedWith(40120, 'card.ownerRefersTo')); + // never deleted: `state` 2 is the delete + await assert.rejects(sdk.documents.delete({ document: defined }), refusedWith(10404)); + await move(defined, 'board', OWNER, { ...board, state: 2 }); +}); + // A lagging node just after an enrolment answers the role read without the writer row: `mRole` is // left out, the member gate refuses (40120), and the write reads the role afresh and rebuilds once. test('a stale role read is re-read once when the member gate refuses', async () => { diff --git a/forge-contracts/scripts/lib/seed-io.mjs b/forge-contracts/scripts/lib/seed-io.mjs index 4cf3e79ec..21e0bb21e 100644 --- a/forge-contracts/scripts/lib/seed-io.mjs +++ b/forge-contracts/scripts/lib/seed-io.mjs @@ -45,10 +45,16 @@ export const CONTRACT_OF = DEFAULT_SET.contractOf; /** * The types forge-meta holds on a four-contract set (DESIGN rev 4.1 D44); a three-contract set - * keeps them in their `CONTRACT_OF` homes, except `vaultEntry` (UPDATE-2, the passkey vault), which - * only the four-contract set has. Parity: forge-core `layout::META_TYPES`, forge-web `lib/layout.ts`. + * keeps them in their `CONTRACT_OF` homes, except `META_ONLY_TYPES`, which only the four-contract + * set has. Parity: forge-core `layout::META_TYPES`, forge-web `lib/layout.ts`. */ -export const META_TYPES = new Set(['repoKey', 'ban', 'label', 'topic', 'packMirror', 'profile', 'follow', 'vaultEntry']); +export const META_TYPES = new Set(['repoKey', 'ban', 'label', 'topic', 'packMirror', 'profile', 'follow', 'vaultEntry', 'board', 'card']); + +/** + * The `META_TYPES` with no three-contract home: `vaultEntry` (UPDATE-2, the passkey vault), `board` + * and `card` (UPDATE-3, docs/design/boards.md §3). Parity: forge-core `layout::META_ONLY_TYPES`. + */ +export const META_ONLY_TYPES = new Set(['vaultEntry', 'board', 'card']); /** * The contract (`core`, `collab`, `community`, `meta`) that holds `type` on the network whose ids diff --git a/forge-contracts/scripts/lib/seed-io.test.mjs b/forge-contracts/scripts/lib/seed-io.test.mjs index 2b01df0e9..7cddf877c 100644 --- a/forge-contracts/scripts/lib/seed-io.test.mjs +++ b/forge-contracts/scripts/lib/seed-io.test.mjs @@ -6,7 +6,7 @@ import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { after, test } from 'node:test'; -import { CONTRACTS, CONTRACT_OF, META_TYPES, ROOT, assertWriteTarget, contractOn, contractsIn, resolveNetwork, shapeData, shapeOfSet } from './seed-io.mjs'; +import { CONTRACTS, CONTRACT_OF, META_ONLY_TYPES, META_TYPES, ROOT, assertWriteTarget, contractOn, contractsIn, resolveNetwork, shapeData, shapeOfSet } from './seed-io.mjs'; const typesOf = (dir, file) => Object.keys(JSON.parse(readFileSync(join(dir, file), 'utf8')).documentSchemas); @@ -35,8 +35,12 @@ test('the committed mainnet set is four contracts, forge-meta last', () => { test('a three-contract record keeps the moved types in their old homes', () => { const ids = { core: 'c', collab: 'l', community: 'm' }; - // (vaultEntry, UPDATE-2, is a four-contract type: the three-contract set has no home for it) - for (const t of META_TYPES) if (t !== 'vaultEntry') assert.equal(contractOn(ids, t), CONTRACT_OF[t], t); + // (vaultEntry, board and card are four-contract types: the three-contract set has no home for them) + for (const t of META_TYPES) { + if (META_ONLY_TYPES.has(t)) assert.equal(contractOn(ids, t), undefined, t); + else assert.equal(contractOn(ids, t), CONTRACT_OF[t], t); + } + for (const t of META_ONLY_TYPES) assert.ok(META_TYPES.has(t), t); }); // ---- the shape of a loaded set decides the fields a write carries (DESIGN MB1) ---- diff --git a/forge-contracts/vectors/board_fold__arch_off.json b/forge-contracts/vectors/board_fold__arch_off.json new file mode 100644 index 000000000..3e10af7dc --- /dev/null +++ b/forge-contracts/vectors/board_fold__arch_off.json @@ -0,0 +1,168 @@ +{ + "name": "arch_off", + "description": "arch 0 turns auto-archive off: an item closed 23 days ago with no card stays in Done.", + "case": "board_fold", + "rules": "v2", + "input": { + "op": "fold", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 0 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "items": [ + { + "id": "4ffa5ETTYcoqTsb1MHqvKzwPDVT2m6GswoJjQ18swZrm", + "number": 54, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791007200000, + "closedAt": 1791072000000, + "title": "Item 54", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [] + }, + "expected": { + "items": [ + { + "id": "4ffa5ETTYcoqTsb1MHqvKzwPDVT2m6GswoJjQ18swZrm", + "on": true, + "sourced": true, + "removed": false, + "card": null, + "col": 3, + "rank": "V0VWxnglEEyoY", + "archived": null, + "fields": {} + } + ], + "columns": [ + { + "id": 1, + "items": [] + }, + { + "id": 2, + "items": [] + }, + { + "id": 3, + "items": [ + "4ffa5ETTYcoqTsb1MHqvKzwPDVT2m6GswoJjQ18swZrm" + ] + }, + { + "id": 4, + "items": [] + } + ] + } +} diff --git a/forge-contracts/vectors/board_fold__auto_archive_boundary.json b/forge-contracts/vectors/board_fold__auto_archive_boundary.json new file mode 100644 index 000000000..ebf475a21 --- /dev/null +++ b/forge-contracts/vectors/board_fold__auto_archive_boundary.json @@ -0,0 +1,361 @@ +{ + "name": "auto_archive_boundary", + "description": "Auto-archive (arch 14) with now pinned: closed exactly 14 days ago → archived (auto); 1 ms later → not; a card written after closing → not; a card written before closing → archived; a card written at the closing instant is not older → not; closedAt unknown → not; open → never. Archived items leave the columns.", + "case": "board_fold", + "rules": "v2", + "input": { + "op": "fold", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "items": [ + { + "id": "3mXCuXaVT4gZ44rxQzNRQ3nH6M7VayprZVz9usETRkYQ", + "number": 41, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1790960400000, + "closedAt": 1791892800000, + "title": "Item 41", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "3qXrE7xFvG5RPk9aLF6h1RsSVCq9gDhw8SrfFsqihRsf", + "number": 42, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1790964000000, + "closedAt": 1791892800001, + "title": "Item 42", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "3uYVYiL2PTUHjRSCFVpxcoxbt4YomTb1hPjAbtSyy7Cv", + "number": 43, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1790967600000, + "closedAt": 1791374400000, + "title": "Item 43", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "3yZ8sJhnresA56ipAkZEEC3mGvGTrhU6GLbfwu4FEnYB", + "number": 44, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "merged", + "createdAt": 1790971200000, + "closedAt": 1791374400000, + "title": "Item 44", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "43ZnBu5ZKrG2Qn1S61HVqa8vfmz7wwMAqHUBHufWWTsS", + "number": 45, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1790974800000, + "closedAt": 1791374400000, + "title": "Item 45", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "47aRWVTKo3etkTJ41G1mSxE64dhn3BEFQELgdvGmn9Ch", + "number": 46, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1790978400000, + "closedAt": null, + "title": "Item 46", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "4Bb4q5q6GF3m68afvWk34LKFTVRS8R7KyBDByvt33pXx", + "number": 47, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1790982000000, + "closedAt": null, + "title": "Item 47", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791460800000, + "item": "3uYVYiL2PTUHjRSCFVpxcoxbt4YomTb1hPjAbtSyy7Cv", + "col": 4, + "rank": null, + "f": null, + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791288000000, + "item": "3yZ8sJhnresA56ipAkZEEC3mGvGTrhU6GLbfwu4FEnYB", + "col": 2, + "rank": null, + "f": null, + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791374400000, + "item": "43ZnBu5ZKrG2Qn1S61HVqa8vfmz7wwMAqHUBHufWWTsS", + "col": 3, + "rank": null, + "f": null, + "state": 0 + } + ] + }, + "expected": { + "items": [ + { + "id": "3mXCuXaVT4gZ44rxQzNRQ3nH6M7VayprZVz9usETRkYQ", + "on": true, + "sourced": true, + "removed": false, + "card": null, + "col": 3, + "rank": "V0VWudJwWBJ4f", + "archived": "auto", + "fields": {} + }, + { + "id": "3qXrE7xFvG5RPk9aLF6h1RsSVCq9gDhw8SrfFsqihRsf", + "on": true, + "sourced": true, + "removed": false, + "card": null, + "col": 3, + "rank": "V0VWusQT2Baao", + "archived": null, + "fields": {} + }, + { + "id": "3uYVYiL2PTUHjRSCFVpxcoxbt4YomTb1hPjAbtSyy7Cv", + "on": true, + "sourced": true, + "removed": false, + "card": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "col": 4, + "rank": "V0VWv7WzYBs6x", + "archived": null, + "fields": {} + }, + { + "id": "3yZ8sJhnresA56ipAkZEEC3mGvGTrhU6GLbfwu4FEnYB", + "on": true, + "sourced": true, + "removed": false, + "card": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "col": 3, + "rank": "V0VWvMdW4C9d6", + "archived": "auto", + "fields": {} + }, + { + "id": "43ZnBu5ZKrG2Qn1S61HVqa8vfmz7wwMAqHUBHufWWTsS", + "on": true, + "sourced": true, + "removed": false, + "card": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "col": 3, + "rank": "V0VWvbk2aCR9F", + "archived": null, + "fields": {} + }, + { + "id": "47aRWVTKo3etkTJ41G1mSxE64dhn3BEFQELgdvGmn9Ch", + "on": true, + "sourced": true, + "removed": false, + "card": null, + "col": 3, + "rank": "V0VWvqqZ6CifO", + "archived": null, + "fields": {} + }, + { + "id": "4Bb4q5q6GF3m68afvWk34LKFTVRS8R7KyBDByvt33pXx", + "on": true, + "sourced": true, + "removed": false, + "card": null, + "col": 1, + "rank": "V0VWw5x5cD0BX", + "archived": null, + "fields": {} + } + ], + "columns": [ + { + "id": 1, + "items": [ + "4Bb4q5q6GF3m68afvWk34LKFTVRS8R7KyBDByvt33pXx" + ] + }, + { + "id": 2, + "items": [] + }, + { + "id": 3, + "items": [ + "3qXrE7xFvG5RPk9aLF6h1RsSVCq9gDhw8SrfFsqihRsf", + "43ZnBu5ZKrG2Qn1S61HVqa8vfmz7wwMAqHUBHufWWTsS", + "47aRWVTKo3etkTJ41G1mSxE64dhn3BEFQELgdvGmn9Ch" + ] + }, + { + "id": 4, + "items": [ + "3uYVYiL2PTUHjRSCFVpxcoxbt4YomTb1hPjAbtSyy7Cv" + ] + } + ] + } +} diff --git a/forge-contracts/vectors/board_fold__bad_rank_and_values.json b/forge-contracts/vectors/board_fold__bad_rank_and_values.json new file mode 100644 index 000000000..a568306ce --- /dev/null +++ b/forge-contracts/vectors/board_fold__bad_rank_and_values.json @@ -0,0 +1,268 @@ +{ + "name": "bad_rank_and_values", + "description": "A card whose rank is absent or not an explicit rank (ends in 0, a bad digit) ranks as if it had none (implicit); a card whose f is not JSON has no values. Repeated items count once.", + "case": "board_fold", + "rules": "v2", + "input": { + "op": "fold", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "items": [ + { + "id": "5qqdEAo4aP1w1P5JbecQqeta1fms6Dez2fuUtznBZyJE", + "number": 71, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791068400000, + "closedAt": null, + "title": "Item 71", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "5urGYmAq3aQoM4MvWuLgT2yjQXVXBTY4bcmzF1PSqedV", + "number": 72, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791072000000, + "closedAt": null, + "title": "Item 72", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "5yrusMYbWmofgjeYSA4x4R4toPDBGhR9AZeVb1zi7Kxk", + "number": 73, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791075600000, + "closedAt": null, + "title": "Item 73", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "5qqdEAo4aP1w1P5JbecQqeta1fms6Dez2fuUtznBZyJE", + "number": 71, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791068400000, + "closedAt": null, + "title": "Item 71", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "5qqdEAo4aP1w1P5JbecQqeta1fms6Dez2fuUtznBZyJE", + "col": 2, + "rank": "AB0", + "f": "{\"2\":", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "5urGYmAq3aQoM4MvWuLgT2yjQXVXBTY4bcmzF1PSqedV", + "col": 2, + "rank": "A-B", + "f": null, + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "5yrusMYbWmofgjeYSA4x4R4toPDBGhR9AZeVb1zi7Kxk", + "col": 2, + "rank": "A", + "f": null, + "state": 0 + } + ] + }, + "expected": { + "items": [ + { + "id": "5qqdEAo4aP1w1P5JbecQqeta1fms6Dez2fuUtznBZyJE", + "on": true, + "sourced": true, + "removed": false, + "card": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "col": 2, + "rank": "V0VX1wTg0JmYt", + "archived": null, + "fields": {} + }, + { + "id": "5urGYmAq3aQoM4MvWuLgT2yjQXVXBTY4bcmzF1PSqedV", + "on": true, + "sourced": true, + "removed": false, + "card": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "col": 2, + "rank": "V0VX2BaCWK452", + "archived": null, + "fields": {} + }, + { + "id": "5yrusMYbWmofgjeYSA4x4R4toPDBGhR9AZeVb1zi7Kxk", + "on": true, + "sourced": true, + "removed": false, + "card": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "col": 2, + "rank": "A", + "archived": null, + "fields": {} + } + ], + "columns": [ + { + "id": 1, + "items": [] + }, + { + "id": 2, + "items": [ + "5yrusMYbWmofgjeYSA4x4R4toPDBGhR9AZeVb1zi7Kxk", + "5qqdEAo4aP1w1P5JbecQqeta1fms6Dez2fuUtznBZyJE", + "5urGYmAq3aQoM4MvWuLgT2yjQXVXBTY4bcmzF1PSqedV" + ] + }, + { + "id": 3, + "items": [] + }, + { + "id": 4, + "items": [] + } + ] + } +} diff --git a/forge-contracts/vectors/board_fold__boards_newest.json b/forge-contracts/vectors/board_fold__boards_newest.json new file mode 100644 index 000000000..6ee07c4ea --- /dev/null +++ b/forge-contracts/vectors/board_fold__boards_newest.json @@ -0,0 +1,78 @@ +{ + "name": "boards_newest", + "description": "Board revisions: per key the newest over every member's by ($updatedAt, $id), ascending by key; a newest revision with state 2 deletes the board (another member's older open revision does not bring it back); an older deleted revision does not.", + "case": "board_fold", + "rules": "v2", + "input": { + "op": "boards", + "docs": [ + { + "id": "CZAKsFwL5dVHb1TA5jaZrrkF8PUZybTyDd3A4YBfbkVQ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1790812800100, + "key": 7, + "state": 0, + "name": "B7", + "spec": null + }, + { + "id": "CdAyBrK6Ypt9vgjmzzJqUEqQXFCE4qM3nZufQYnvsRpf", + "ownerId": "FFftTC944VmyJQ2VaUDieXSMpssQULQkDB9odPorkphY", + "updatedAt": 1790812800150, + "key": 7, + "state": 2, + "name": "B7", + "spec": null + }, + { + "id": "AhBcWSgs22H2GN2PvF375cvZv6utA5E8MWnAkZQC979v", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1790812800050, + "key": 3, + "state": 0, + "name": "B3", + "spec": null + }, + { + "id": "bhBcWSgs22H2GN2PvF375cvZv6utA5E8MWnAkZQC979v", + "ownerId": "FFftTC944VmyJQ2VaUDieXSMpssQULQkDB9odPorkphY", + "updatedAt": 1790812800050, + "key": 3, + "state": 1, + "name": "B3", + "spec": null + }, + { + "id": "D7Eb8ru2td9a5RMt4ondt5tyNrLVVZvNByoMTSMbo3wY", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1790812800010, + "key": 9, + "state": 1, + "name": "B9", + "spec": null + }, + { + "id": "D3DwpGXGRRkhjk5G9Z4NGhooyzcqQL3Hd2vr7RkLXNcH", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1790812800005, + "key": 9, + "state": 2, + "name": "B9", + "spec": null + } + ], + "withDeleted": false + }, + "expected": [ + { + "key": 3, + "id": "bhBcWSgs22H2GN2PvF375cvZv6utA5E8MWnAkZQC979v", + "state": 1 + }, + { + "key": 9, + "id": "D7Eb8ru2td9a5RMt4ondt5tyNrLVVZvNByoMTSMbo3wY", + "state": 1 + } + ] +} diff --git a/forge-contracts/vectors/board_fold__boards_with_deleted.json b/forge-contracts/vectors/board_fold__boards_with_deleted.json new file mode 100644 index 000000000..84df77dd1 --- /dev/null +++ b/forge-contracts/vectors/board_fold__boards_with_deleted.json @@ -0,0 +1,83 @@ +{ + "name": "boards_with_deleted", + "description": "The same revisions with the deleted boards kept.", + "case": "board_fold", + "rules": "v2", + "input": { + "op": "boards", + "docs": [ + { + "id": "CZAKsFwL5dVHb1TA5jaZrrkF8PUZybTyDd3A4YBfbkVQ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1790812800100, + "key": 7, + "state": 0, + "name": "B7", + "spec": null + }, + { + "id": "CdAyBrK6Ypt9vgjmzzJqUEqQXFCE4qM3nZufQYnvsRpf", + "ownerId": "FFftTC944VmyJQ2VaUDieXSMpssQULQkDB9odPorkphY", + "updatedAt": 1790812800150, + "key": 7, + "state": 2, + "name": "B7", + "spec": null + }, + { + "id": "AhBcWSgs22H2GN2PvF375cvZv6utA5E8MWnAkZQC979v", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1790812800050, + "key": 3, + "state": 0, + "name": "B3", + "spec": null + }, + { + "id": "bhBcWSgs22H2GN2PvF375cvZv6utA5E8MWnAkZQC979v", + "ownerId": "FFftTC944VmyJQ2VaUDieXSMpssQULQkDB9odPorkphY", + "updatedAt": 1790812800050, + "key": 3, + "state": 1, + "name": "B3", + "spec": null + }, + { + "id": "D7Eb8ru2td9a5RMt4ondt5tyNrLVVZvNByoMTSMbo3wY", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1790812800010, + "key": 9, + "state": 1, + "name": "B9", + "spec": null + }, + { + "id": "D3DwpGXGRRkhjk5G9Z4NGhooyzcqQL3Hd2vr7RkLXNcH", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1790812800005, + "key": 9, + "state": 2, + "name": "B9", + "spec": null + } + ], + "withDeleted": true + }, + "expected": [ + { + "key": 3, + "id": "bhBcWSgs22H2GN2PvF375cvZv6utA5E8MWnAkZQC979v", + "state": 1 + }, + { + "key": 7, + "id": "CdAyBrK6Ypt9vgjmzzJqUEqQXFCE4qM3nZufQYnvsRpf", + "state": 2 + }, + { + "key": 9, + "id": "D7Eb8ru2td9a5RMt4ondt5tyNrLVVZvNByoMTSMbo3wY", + "state": 1 + } + ] +} diff --git a/forge-contracts/vectors/board_fold__newest_card.json b/forge-contracts/vectors/board_fold__newest_card.json new file mode 100644 index 000000000..fe91cc9b6 --- /dev/null +++ b/forge-contracts/vectors/board_fold__newest_card.json @@ -0,0 +1,248 @@ +{ + "name": "newest_card", + "description": "The newest card over every member's wins whole, by ($updatedAt, $id): a later card of another member replaces the column and the field values; on equal $updatedAt the greater $id (by code point) wins. A card's values for unknown fields or options are dropped.", + "case": "board_fold", + "rules": "v2", + "input": { + "op": "fold", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "items": [ + { + "id": "2TDdSJqfuYnZuDdmvNgZxBJqNcCTh5uRMf5mt35Mi7mW", + "number": 21, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1790888400000, + "closedAt": null, + "title": "Item 21", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "2XEGkuDSNkBSEtvPqdQqZZPzmTv7nKnVvbxHE3gcyo6m", + "number": 22, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1790892000000, + "closedAt": null, + "title": "Item 22", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1790812800100, + "item": "2TDdSJqfuYnZuDdmvNgZxBJqNcCTh5uRMf5mt35Mi7mW", + "col": 2, + "rank": null, + "f": "{\"1\":1,\"2\":5}", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FFftTC944VmyJQ2VaUDieXSMpssQULQkDB9odPorkphY", + "updatedAt": 1790812800200, + "item": "2TDdSJqfuYnZuDdmvNgZxBJqNcCTh5uRMf5mt35Mi7mW", + "col": 4, + "rank": null, + "f": "{\"2\":3,\"1\":9,\"7\":1}", + "state": 0 + }, + { + "id": "56whRx6fB5hignpPAMtzugSQknH7HWZYrxxPBW7Jtdiu", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1790812800300, + "item": "2XEGkuDSNkBSEtvPqdQqZZPzmTv7nKnVvbxHE3gcyo6m", + "col": 2, + "rank": null, + "f": null, + "state": 0 + }, + { + "id": "z6whRx6fB5hignpPAMtzugSQknH7HWZYrxxPBW7Jtdiu", + "ownerId": "FFftTC944VmyJQ2VaUDieXSMpssQULQkDB9odPorkphY", + "updatedAt": 1790812800300, + "item": "2XEGkuDSNkBSEtvPqdQqZZPzmTv7nKnVvbxHE3gcyo6m", + "col": 4, + "rank": null, + "f": null, + "state": 0 + }, + { + "id": "A6whRx6fB5hignpPAMtzugSQknH7HWZYrxxPBW7Jtdiu", + "ownerId": "FFftTC944VmyJQ2VaUDieXSMpssQULQkDB9odPorkphY", + "updatedAt": 1790812800300, + "item": "2XEGkuDSNkBSEtvPqdQqZZPzmTv7nKnVvbxHE3gcyo6m", + "col": 1, + "rank": null, + "f": null, + "state": 0 + } + ] + }, + "expected": { + "items": [ + { + "id": "2TDdSJqfuYnZuDdmvNgZxBJqNcCTh5uRMf5mt35Mi7mW", + "on": true, + "sourced": true, + "removed": false, + "card": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "col": 4, + "rank": "V0VWplDSC5vov", + "archived": null, + "fields": { + "2": 3 + } + }, + { + "id": "2XEGkuDSNkBSEtvPqdQqZZPzmTv7nKnVvbxHE3gcyo6m", + "on": true, + "sourced": true, + "removed": false, + "card": "z6whRx6fB5hignpPAMtzugSQknH7HWZYrxxPBW7Jtdiu", + "col": 4, + "rank": "V0VWq0Jyi6DL4", + "archived": null, + "fields": {} + } + ], + "columns": [ + { + "id": 1, + "items": [] + }, + { + "id": 2, + "items": [] + }, + { + "id": 3, + "items": [] + }, + { + "id": 4, + "items": [ + "2TDdSJqfuYnZuDdmvNgZxBJqNcCTh5uRMf5mt35Mi7mW", + "2XEGkuDSNkBSEtvPqdQqZZPzmTv7nKnVvbxHE3gcyo6m" + ] + } + ] + } +} diff --git a/forge-contracts/vectors/board_fold__no_done_no_default.json b/forge-contracts/vectors/board_fold__no_done_no_default.json new file mode 100644 index 000000000..9ffc3b8fd --- /dev/null +++ b/forge-contracts/vectors/board_fold__no_done_no_default.json @@ -0,0 +1,182 @@ +{ + "name": "no_done_no_default", + "description": "A board without a Done column applies only \"the card's column, else the default\"; with default 0 the items without a column show in \"No status\" (column 0, listed first while it holds an item).", + "case": "board_fold", + "rules": "v2", + "input": { + "op": "fold", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Backlog" + }, + { + "id": 2, + "name": "Doing" + } + ], + "sources": [ + { + "k": "i" + } + ] + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "items": [ + { + "id": "59jC2F3PtR5FccD7R7Kijqzx56bJBprCMDCRSthYsBye", + "number": 61, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791032400000, + "closedAt": null, + "title": "Item 61", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "5DjqLqRAMcU7xHVjLN3zME67TxJxH4jGvA4vnuJp8sJu", + "number": 62, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791036000000, + "closedAt": 1793016000000, + "title": "Item 62", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "5HkUfRnvporzHxnMFcnFxcBGrp2cNJcMV6wS8uv5QYeA", + "number": 63, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791039600000, + "closedAt": 1793016000000, + "title": "Item 63", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "5Mm7z2AhJ1Frde4yAsWXZzGSFfkGTYVS43owUvXLgDyR", + "number": 64, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "open", + "createdAt": 1791043200000, + "closedAt": null, + "title": "Item 64", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "5HkUfRnvporzHxnMFcnFxcBGrp2cNJcMV6wS8uv5QYeA", + "col": 2, + "rank": null, + "f": null, + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "5Mm7z2AhJ1Frde4yAsWXZzGSFfkGTYVS43owUvXLgDyR", + "col": 1, + "rank": null, + "f": null, + "state": 0 + } + ] + }, + "expected": { + "items": [ + { + "id": "59jC2F3PtR5FccD7R7Kijqzx56bJBprCMDCRSthYsBye", + "on": true, + "sourced": true, + "removed": false, + "card": null, + "col": 0, + "rank": "V0VWzVQQqGxNR", + "archived": null, + "fields": {} + }, + { + "id": "5DjqLqRAMcU7xHVjLN3zME67TxJxH4jGvA4vnuJp8sJu", + "on": true, + "sourced": true, + "removed": false, + "card": null, + "col": 0, + "rank": "V0VWzkWxMHEta", + "archived": null, + "fields": {} + }, + { + "id": "5HkUfRnvporzHxnMFcnFxcBGrp2cNJcMV6wS8uv5QYeA", + "on": true, + "sourced": true, + "removed": false, + "card": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "col": 2, + "rank": "V0VWzzdTsHWPj", + "archived": null, + "fields": {} + }, + { + "id": "5Mm7z2AhJ1Frde4yAsWXZzGSFfkGTYVS43owUvXLgDyR", + "on": true, + "sourced": false, + "removed": false, + "card": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "col": 1, + "rank": "V0VX0Ek0OHnvs", + "archived": null, + "fields": {} + } + ], + "columns": [ + { + "id": 0, + "items": [ + "59jC2F3PtR5FccD7R7Kijqzx56bJBprCMDCRSthYsBye", + "5DjqLqRAMcU7xHVjLN3zME67TxJxH4jGvA4vnuJp8sJu" + ] + }, + { + "id": 1, + "items": [ + "5Mm7z2AhJ1Frde4yAsWXZzGSFfkGTYVS43owUvXLgDyR" + ] + }, + { + "id": 2, + "items": [ + "5HkUfRnvporzHxnMFcnFxcBGrp2cNJcMV6wS8uv5QYeA" + ] + } + ] + } +} diff --git a/forge-contracts/vectors/board_fold__placement.json b/forge-contracts/vectors/board_fold__placement.json new file mode 100644 index 000000000..33c1e34b1 --- /dev/null +++ b/forge-contracts/vectors/board_fold__placement.json @@ -0,0 +1,484 @@ +{ + "name": "placement", + "description": "Columns (§2.4): no card → default (Todo); a card's column; closed → Done; merged with a card in Verified (after Done) stays; closed with a card before Done → Done; open in Done stays; another repo's item added by a card shows; another repo's item with no card is off (no source matches it); a card naming a column the spec no longer has, or none (0), → default. Each column in rank order (cards' ranks, else implicit).", + "case": "board_fold", + "rules": "v2", + "input": { + "op": "fold", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "items": [ + { + "id": "51eKbNmUCPsLgHcvFjGcP6APrif6Et5ZwsWM1cGGgLG", + "number": 1, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1790816400000, + "closedAt": null, + "title": "Item 1", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "92HeBkXwPnjgMaEqWTYDmBKniSKBUmA8tk1h2DXYMfX", + "number": 2, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1790820000000, + "closedAt": null, + "title": "Item 2", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "D2vxn8JQbBc22rrkmBoq9GVBa9yGieEhqcX32pnp2zn", + "number": 3, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1790823600000, + "closedAt": 1793016000000, + "title": "Item 3", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "H3aHNW4snaUMi9Ug1v5SXMeaRsdMxXKGnV2P3S45iL3", + "number": 4, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "merged", + "createdAt": 1790827200000, + "closedAt": 1793016000000, + "title": "Item 4", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "M4DbxsqLyyLhPS6bGeM3uSoyHbHTCQPqjMXj43KMPfJ", + "number": 5, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1790830800000, + "closedAt": 1793016000000, + "title": "Item 5", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "R4rvZFbpBND34iiWXNcfHXyN9JwYSHUQgE354ead4zZ", + "number": 6, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1790834400000, + "closedAt": null, + "title": "Item 6", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "V5WF9dNHNm5Nk1LRn6tGfd8m12bdgAYyd6YR5FqtkKp", + "number": 7, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "bob/lib", + "kind": "issue", + "state": "open", + "createdAt": 1790838000000, + "closedAt": null, + "title": "Item 7", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "Z69Zk18ka9wiRHxM2q9t3iJ9rkFiv3dYZy3m5s7ARf5", + "number": 8, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "bob/lib", + "kind": "issue", + "state": "open", + "createdAt": 1790841600000, + "closedAt": null, + "title": "Item 8", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "d6ntLNuDmYp46aaGHZRVRoTYiTup9vi7WqZ76UNS6zL", + "number": 9, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1790845200000, + "closedAt": null, + "title": "Item 9", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "h7SCvkfgxwgPmsCBYHh6otcwaBZuPongTi4T75dhnKb", + "number": 10, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1790848800000, + "closedAt": null, + "title": "Item 10", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "92HeBkXwPnjgMaEqWTYDmBKniSKBUmA8tk1h2DXYMfX", + "col": 2, + "rank": "F", + "f": null, + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "H3aHNW4snaUMi9Ug1v5SXMeaRsdMxXKGnV2P3S45iL3", + "col": 4, + "rank": null, + "f": null, + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "M4DbxsqLyyLhPS6bGeM3uSoyHbHTCQPqjMXj43KMPfJ", + "col": 2, + "rank": null, + "f": null, + "state": 0 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244804000, + "item": "R4rvZFbpBND34iiWXNcfHXyN9JwYSHUQgE354ead4zZ", + "col": 3, + "rank": null, + "f": null, + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244805000, + "item": "V5WF9dNHNm5Nk1LRn6tGfd8m12bdgAYyd6YR5FqtkKp", + "col": 2, + "rank": "l", + "f": null, + "state": 0 + }, + { + "id": "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244806000, + "item": "d6ntLNuDmYp46aaGHZRVRoTYiTup9vi7WqZ76UNS6zL", + "col": 9, + "rank": "G", + "f": null, + "state": 0 + }, + { + "id": "8GJcXjVigTj9N4WARNLVBoE38jJ5E15SkSY75oyKeLBL", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244807000, + "item": "h7SCvkfgxwgPmsCBYHh6otcwaBZuPongTi4T75dhnKb", + "col": 0, + "rank": null, + "f": null, + "state": 0 + } + ] + }, + "expected": { + "items": [ + { + "id": "51eKbNmUCPsLgHcvFjGcP6APrif6Et5ZwsWM1cGGgLG", + "on": true, + "sourced": true, + "removed": false, + "card": null, + "col": 1, + "rank": "V0VWkt6xs0HW9", + "archived": null, + "fields": {} + }, + { + "id": "92HeBkXwPnjgMaEqWTYDmBKniSKBUmA8tk1h2DXYMfX", + "on": true, + "sourced": true, + "removed": false, + "card": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "col": 2, + "rank": "F", + "archived": null, + "fields": {} + }, + { + "id": "D2vxn8JQbBc22rrkmBoq9GVBa9yGieEhqcX32pnp2zn", + "on": true, + "sourced": true, + "removed": false, + "card": null, + "col": 3, + "rank": "V0VWlNK0u0qYR", + "archived": null, + "fields": {} + }, + { + "id": "H3aHNW4snaUMi9Ug1v5SXMeaRsdMxXKGnV2P3S45iL3", + "on": true, + "sourced": true, + "removed": false, + "card": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "col": 4, + "rank": "V0VWlcQXQ184a", + "archived": null, + "fields": {} + }, + { + "id": "M4DbxsqLyyLhPS6bGeM3uSoyHbHTCQPqjMXj43KMPfJ", + "on": true, + "sourced": true, + "removed": false, + "card": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "col": 3, + "rank": "V0VWlrX3w1Paj", + "archived": null, + "fields": {} + }, + { + "id": "R4rvZFbpBND34iiWXNcfHXyN9JwYSHUQgE354ead4zZ", + "on": true, + "sourced": true, + "removed": false, + "card": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "col": 3, + "rank": "V0VWm6daS1h6s", + "archived": null, + "fields": {} + }, + { + "id": "V5WF9dNHNm5Nk1LRn6tGfd8m12bdgAYyd6YR5FqtkKp", + "on": true, + "sourced": false, + "removed": false, + "card": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "col": 2, + "rank": "l", + "archived": null, + "fields": {} + }, + { + "id": "Z69Zk18ka9wiRHxM2q9t3iJ9rkFiv3dYZy3m5s7ARf5", + "on": false, + "sourced": false, + "removed": false, + "card": null, + "col": 1, + "rank": "V0VWmaqdU2G9A", + "archived": null, + "fields": {} + }, + { + "id": "d6ntLNuDmYp46aaGHZRVRoTYiTup9vi7WqZ76UNS6zL", + "on": true, + "sourced": true, + "removed": false, + "card": "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5", + "col": 1, + "rank": "G", + "archived": null, + "fields": {} + }, + { + "id": "h7SCvkfgxwgPmsCBYHh6otcwaBZuPongTi4T75dhnKb", + "on": true, + "sourced": true, + "removed": false, + "card": "8GJcXjVigTj9N4WARNLVBoE38jJ5E15SkSY75oyKeLBL", + "col": 1, + "rank": "V0VWn53gW2pBS", + "archived": null, + "fields": {} + } + ], + "columns": [ + { + "id": 1, + "items": [ + "d6ntLNuDmYp46aaGHZRVRoTYiTup9vi7WqZ76UNS6zL", + "51eKbNmUCPsLgHcvFjGcP6APrif6Et5ZwsWM1cGGgLG", + "h7SCvkfgxwgPmsCBYHh6otcwaBZuPongTi4T75dhnKb" + ] + }, + { + "id": 2, + "items": [ + "92HeBkXwPnjgMaEqWTYDmBKniSKBUmA8tk1h2DXYMfX", + "V5WF9dNHNm5Nk1LRn6tGfd8m12bdgAYyd6YR5FqtkKp" + ] + }, + { + "id": 3, + "items": [ + "D2vxn8JQbBc22rrkmBoq9GVBa9yGieEhqcX32pnp2zn", + "M4DbxsqLyyLhPS6bGeM3uSoyHbHTCQPqjMXj43KMPfJ", + "R4rvZFbpBND34iiWXNcfHXyN9JwYSHUQgE354ead4zZ" + ] + }, + { + "id": 4, + "items": [ + "H3aHNW4snaUMi9Ug1v5SXMeaRsdMxXKGnV2P3S45iL3" + ] + } + ] + } +} diff --git a/forge-contracts/vectors/board_fold__removed.json b/forge-contracts/vectors/board_fold__removed.json new file mode 100644 index 000000000..ef29cd7d3 --- /dev/null +++ b/forge-contracts/vectors/board_fold__removed.json @@ -0,0 +1,271 @@ +{ + "name": "removed", + "description": "A removed card (state 2) takes the item off the board even though a source matches it; an older member's active card does not bring it back; a newer active card (adding it again) does. An unsourced item whose newest card is removed is off too.", + "case": "board_fold", + "rules": "v2", + "input": { + "op": "fold", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "items": [ + { + "id": "39L4eEbLbWjFHzVy6uyG3zCTKBP2bUiD37nqL99zQu66", + "number": 31, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1790924400000, + "closedAt": null, + "title": "Item 31", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "3DLhxpy74i87dfnb2AhXfNHci36ggibHc4fLg9mFgaRM", + "number": 32, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1790928000000, + "closedAt": null, + "title": "Item 32", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "3HMMHRLsXuWyyM5CwRRoGkNn6tpLmxUNB1Xr2ANWxFkc", + "number": 33, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1790931600000, + "closedAt": null, + "title": "Item 33", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1790812800100, + "item": "39L4eEbLbWjFHzVy6uyG3zCTKBP2bUiD37nqL99zQu66", + "col": 2, + "rank": null, + "f": null, + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FFftTC944VmyJQ2VaUDieXSMpssQULQkDB9odPorkphY", + "updatedAt": 1790812800200, + "item": "39L4eEbLbWjFHzVy6uyG3zCTKBP2bUiD37nqL99zQu66", + "col": null, + "rank": null, + "f": null, + "state": 2 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FFftTC944VmyJQ2VaUDieXSMpssQULQkDB9odPorkphY", + "updatedAt": 1790812800100, + "item": "3DLhxpy74i87dfnb2AhXfNHci36ggibHc4fLg9mFgaRM", + "col": null, + "rank": null, + "f": null, + "state": 2 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1790812800200, + "item": "3DLhxpy74i87dfnb2AhXfNHci36ggibHc4fLg9mFgaRM", + "col": 2, + "rank": null, + "f": null, + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1790812800100, + "item": "3HMMHRLsXuWyyM5CwRRoGkNn6tpLmxUNB1Xr2ANWxFkc", + "col": 2, + "rank": null, + "f": null, + "state": 2 + } + ] + }, + "expected": { + "items": [ + { + "id": "39L4eEbLbWjFHzVy6uyG3zCTKBP2bUiD37nqL99zQu66", + "on": false, + "sourced": true, + "removed": true, + "card": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "col": 1, + "rank": "V0VWsCGhM8l0N", + "archived": null, + "fields": {} + }, + { + "id": "3DLhxpy74i87dfnb2AhXfNHci36ggibHc4fLg9mFgaRM", + "on": true, + "sourced": true, + "removed": false, + "card": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "col": 2, + "rank": "V0VWsRNDs92WW", + "archived": null, + "fields": {} + }, + { + "id": "3HMMHRLsXuWyyM5CwRRoGkNn6tpLmxUNB1Xr2ANWxFkc", + "on": false, + "sourced": false, + "removed": true, + "card": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "col": 2, + "rank": "V0VWsgTkO9K2f", + "archived": null, + "fields": {} + } + ], + "columns": [ + { + "id": 1, + "items": [] + }, + { + "id": 2, + "items": [ + "3DLhxpy74i87dfnb2AhXfNHci36ggibHc4fLg9mFgaRM" + ] + }, + { + "id": 3, + "items": [] + }, + { + "id": 4, + "items": [] + } + ] + } +} diff --git a/forge-contracts/vectors/board_fold__reopened_archived.json b/forge-contracts/vectors/board_fold__reopened_archived.json new file mode 100644 index 000000000..6555465b4 --- /dev/null +++ b/forge-contracts/vectors/board_fold__reopened_archived.json @@ -0,0 +1,241 @@ +{ + "name": "reopened_archived", + "description": "Reopening never clears a card's archived state: a reopened item whose newest card is archived (state 1) stays archived (card). Auto-archive reads only closed and merged items: one closed 23 days ago is archived (auto), and a reopened one with an old active card is not.", + "case": "board_fold", + "rules": "v2", + "input": { + "op": "fold", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "items": [ + { + "id": "4Tde7TLA92dESqj9bXf7Vrfu2vJ4VNdeExhDMyK68Xrz", + "number": 51, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1790996400000, + "closedAt": null, + "title": "Item 51", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "4XeHS3hvcE26nX1mWnPP7Em4Rn1iacWiouZihyvMQDCF", + "number": 52, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791000000000, + "closedAt": 1791072000000, + "title": "Item 52", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "4bevke5h5RQy8CJPS37eicrDpdjNfrPoNrSE3zXcftXW", + "number": 53, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791003600000, + "closedAt": null, + "title": "Item 53", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791158400000, + "item": "4Tde7TLA92dESqj9bXf7Vrfu2vJ4VNdeExhDMyK68Xrz", + "col": 2, + "rank": null, + "f": null, + "state": 1 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791158400000, + "item": "4bevke5h5RQy8CJPS37eicrDpdjNfrPoNrSE3zXcftXW", + "col": 2, + "rank": null, + "f": null, + "state": 0 + } + ] + }, + "expected": { + "items": [ + { + "id": "4Tde7TLA92dESqj9bXf7Vrfu2vJ4VNdeExhDMyK68Xrz", + "on": true, + "sourced": true, + "removed": false, + "card": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "col": 2, + "rank": "V0VWx4NBgE8G7", + "archived": "card", + "fields": {} + }, + { + "id": "4XeHS3hvcE26nX1mWnPP7Em4Rn1iacWiouZihyvMQDCF", + "on": true, + "sourced": true, + "removed": false, + "card": null, + "col": 3, + "rank": "V0VWxJTiCEPmG", + "archived": "auto", + "fields": {} + }, + { + "id": "4bevke5h5RQy8CJPS37eicrDpdjNfrPoNrSE3zXcftXW", + "on": true, + "sourced": true, + "removed": false, + "card": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "col": 2, + "rank": "V0VWxYaEiEhIP", + "archived": null, + "fields": {} + } + ], + "columns": [ + { + "id": 1, + "items": [] + }, + { + "id": 2, + "items": [ + "4bevke5h5RQy8CJPS37eicrDpdjNfrPoNrSE3zXcftXW" + ] + }, + { + "id": 3, + "items": [] + }, + { + "id": 4, + "items": [] + } + ] + } +} diff --git a/forge-contracts/vectors/board_fold__same_block.json b/forge-contracts/vectors/board_fold__same_block.json new file mode 100644 index 000000000..e8aadf7a5 --- /dev/null +++ b/forge-contracts/vectors/board_fold__same_block.json @@ -0,0 +1,260 @@ +{ + "name": "same_block", + "description": "Items created in one block (equal $createdAt) and no cards: their implicit ranks differ by the first bytes of their ids, so their order is fixed; a card dropped between two of them (rankBetween of their implicit ranks) lands between.", + "case": "board_fold", + "rules": "v2", + "input": { + "op": "fold", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "items": [ + { + "id": "m85XX8SAALYjT9p6o1xiBynLRuDzdgsFQaZo7gtyTer", + "number": 11, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1790812800000, + "closedAt": null, + "title": "Item 11", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "q8ir7WCdMjR58SS23kEKa4wjHct5sZwpMT598JAF8z7", + "number": 12, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1790812800000, + "closedAt": null, + "title": "Item 12", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "u9NAhsy6Z8HQoj3wJUVvxA789LYB7T2PJKaV8uRWpKN", + "number": 13, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1790812800000, + "closedAt": null, + "title": "Item 13", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "yA1VJFjZkX9kV1frZCmYLFGX14CGML6xFC5q9WgnVed", + "number": 14, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1790812800001, + "closedAt": null, + "title": "Item 14", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "yA1VJFjZkX9kV1frZCmYLFGX14CGML6xFC5q9WgnVed", + "col": 1, + "rank": "V0VWke0RM3O", + "f": null, + "state": 0 + } + ] + }, + "expected": { + "items": [ + { + "id": "m85XX8SAALYjT9p6o1xiBynLRuDzdgsFQaZo7gtyTer", + "on": true, + "sourced": true, + "removed": false, + "card": null, + "col": 1, + "rank": "V0VWke0RM36hb", + "archived": null, + "fields": {} + }, + { + "id": "q8ir7WCdMjR58SS23kEKa4wjHct5sZwpMT598JAF8z7", + "on": true, + "sourced": true, + "removed": false, + "card": null, + "col": 1, + "rank": "V0VWke0RM3ODk", + "archived": null, + "fields": {} + }, + { + "id": "u9NAhsy6Z8HQoj3wJUVvxA789LYB7T2PJKaV8uRWpKN", + "on": true, + "sourced": true, + "removed": false, + "card": null, + "col": 1, + "rank": "V0VWke0RM3fjt", + "archived": null, + "fields": {} + }, + { + "id": "yA1VJFjZkX9kV1frZCmYLFGX14CGML6xFC5q9WgnVed", + "on": true, + "sourced": true, + "removed": false, + "card": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "col": 1, + "rank": "V0VWke0RM3O", + "archived": null, + "fields": {} + } + ], + "columns": [ + { + "id": 1, + "items": [ + "m85XX8SAALYjT9p6o1xiBynLRuDzdgsFQaZo7gtyTer", + "yA1VJFjZkX9kV1frZCmYLFGX14CGML6xFC5q9WgnVed", + "q8ir7WCdMjR58SS23kEKa4wjHct5sZwpMT598JAF8z7", + "u9NAhsy6Z8HQoj3wJUVvxA789LYB7T2PJKaV8uRWpKN" + ] + }, + { + "id": 2, + "items": [] + }, + { + "id": 3, + "items": [] + }, + { + "id": 4, + "items": [] + } + ] + } +} diff --git a/forge-contracts/vectors/board_fold__sources.json b/forge-contracts/vectors/board_fold__sources.json new file mode 100644 index 000000000..52269301e --- /dev/null +++ b/forge-contracts/vectors/board_fold__sources.json @@ -0,0 +1,309 @@ +{ + "name": "sources", + "description": "Sources (§2.3): issues of the home repo labelled bug, and open PRs of another repo. A source query applies only item qualifiers: its status: and field qualifiers are ignored (unresolved), so \"status:Todo label:bug\" includes every home issue labelled bug. A PR of the home repo does not match an issues source.", + "case": "board_fold", + "rules": "v2", + "input": { + "op": "fold", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "i", + "q": "status:Todo LABEL:bug" + }, + { + "r": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "k": "p", + "q": "is:open" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "items": [ + { + "id": "6U2mVTnDRvyEmTSHuj1aBiUPnqWL5imdZ46oUireapkY", + "number": 81, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791104400000, + "closedAt": null, + "title": "Item 81", + "labels": [ + "Bug" + ], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "6Y3Qp49yu8N778iupyjqo6ZZBhDzAxei7zyJpjTurW5o", + "number": 82, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791108000000, + "closedAt": null, + "title": "Item 82", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "6c448eXkNKkySp1XkEU7QUeiaYweGCXngwqpAk5B8BR4", + "number": 83, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "open", + "createdAt": 1791111600000, + "closedAt": null, + "title": "Item 83", + "labels": [ + "bug" + ], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "6g4hTEuWqX9qnVJ9fVCP1rjsyQfJMSQsFtiKWkgSPrkK", + "number": 84, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "alice/forge", + "kind": "pr", + "state": "open", + "createdAt": 1791115200000, + "closedAt": null, + "title": "Item 84", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "6k5LmqHHJiYi8AamajvedEq3NGNxSgHwpqaprmHhfY5a", + "number": 85, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "alice/forge", + "kind": "pr", + "state": "merged", + "createdAt": 1791118800000, + "closedAt": 1793016000000, + "title": "Item 85", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "6p5z6Rf3muwaTqsPVzevEcvCm86cXvB2PnTLCmtxwDQq", + "number": 86, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791122400000, + "closedAt": null, + "title": "Item 86", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [] + }, + "expected": { + "items": [ + { + "id": "6U2mVTnDRvyEmTSHuj1aBiUPnqWL5imdZ46oUireapkY", + "on": true, + "sourced": true, + "removed": false, + "card": null, + "col": 1, + "rank": "V0VX4NWvAMKdB", + "archived": null, + "fields": {} + }, + { + "id": "6Y3Qp49yu8N778iupyjqo6ZZBhDzAxei7zyJpjTurW5o", + "on": false, + "sourced": false, + "removed": false, + "card": null, + "col": 1, + "rank": "V0VX4cdRgMc9K", + "archived": null, + "fields": {} + }, + { + "id": "6c448eXkNKkySp1XkEU7QUeiaYweGCXngwqpAk5B8BR4", + "on": false, + "sourced": false, + "removed": false, + "card": null, + "col": 1, + "rank": "V0VX4rjyCMtfT", + "archived": null, + "fields": {} + }, + { + "id": "6g4hTEuWqX9qnVJ9fVCP1rjsyQfJMSQsFtiKWkgSPrkK", + "on": true, + "sourced": true, + "removed": false, + "card": null, + "col": 1, + "rank": "V0VX56qUiNBBc", + "archived": null, + "fields": {} + }, + { + "id": "6k5LmqHHJiYi8AamajvedEq3NGNxSgHwpqaprmHhfY5a", + "on": false, + "sourced": false, + "removed": false, + "card": null, + "col": 3, + "rank": "V0VX5Lx1ENShl", + "archived": null, + "fields": {} + }, + { + "id": "6p5z6Rf3muwaTqsPVzevEcvCm86cXvB2PnTLCmtxwDQq", + "on": false, + "sourced": false, + "removed": false, + "card": null, + "col": 1, + "rank": "V0VX5b3XkNkDu", + "archived": null, + "fields": {} + } + ], + "columns": [ + { + "id": 1, + "items": [ + "6U2mVTnDRvyEmTSHuj1aBiUPnqWL5imdZ46oUireapkY", + "6g4hTEuWqX9qnVJ9fVCP1rjsyQfJMSQsFtiKWkgSPrkK" + ] + }, + { + "id": 2, + "items": [] + }, + { + "id": 3, + "items": [] + }, + { + "id": 4, + "items": [] + } + ] + } +} diff --git a/forge-contracts/vectors/board_iteration__at.json b/forge-contracts/vectors/board_iteration__at.json new file mode 100644 index 000000000..dde6e00da --- /dev/null +++ b/forge-contracts/vectors/board_iteration__at.json @@ -0,0 +1,134 @@ +{ + "name": "at", + "description": "iterationAt: the iteration holding a time (UTC days): none before the first; the last millisecond of iteration 0; the first of 1; far later; past index 65535 none.", + "case": "board_iteration", + "rules": "v2", + "input": { + "op": "at", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "field": 3, + "dates": [ + 1791763199999, + 1791763200000, + 1792972799999, + 1792972800000, + 1793102400000, + 1798761600000, + 81062899200000, + 81064108800000 + ] + }, + "expected": [ + null, + 0, + 0, + 1, + 1, + 5, + 65535, + null + ] +} diff --git a/forge-contracts/vectors/board_iteration__range.json b/forge-contracts/vectors/board_iteration__range.json new file mode 100644 index 000000000..18e1dbe86 --- /dev/null +++ b/forge-contracts/vectors/board_iteration__range.json @@ -0,0 +1,158 @@ +{ + "name": "range", + "description": "iterationRange: iteration k runs from start + k·days for days days, named \" k+1\"; across a year end; the last index; past it none.", + "case": "board_iteration", + "rules": "v2", + "input": { + "op": "range", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "field": 3, + "ks": [ + 0, + 1, + 6, + 65535, + 65536, + -1 + ] + }, + "expected": [ + { + "index": 0, + "name": "Iteration 1", + "start": "2026-10-12", + "end": "2026-10-25", + "startMs": 1791763200000, + "endMs": 1792972800000 + }, + { + "index": 1, + "name": "Iteration 2", + "start": "2026-10-26", + "end": "2026-11-08", + "startMs": 1792972800000, + "endMs": 1794182400000 + }, + { + "index": 6, + "name": "Iteration 7", + "start": "2027-01-04", + "end": "2027-01-17", + "startMs": 1799020800000, + "endMs": 1800230400000 + }, + { + "index": 65535, + "name": "Iteration 65536", + "start": "4538-10-13", + "end": "4538-10-26", + "startMs": 81062899200000, + "endMs": 81064108800000 + }, + null, + null + ] +} diff --git a/forge-contracts/vectors/board_iteration__range_leap_year.json b/forge-contracts/vectors/board_iteration__range_leap_year.json new file mode 100644 index 000000000..a5c4ac299 --- /dev/null +++ b/forge-contracts/vectors/board_iteration__range_leap_year.json @@ -0,0 +1,50 @@ +{ + "name": "range_leap_year", + "description": "Ten-day iterations from 2024-02-20 cross 29 February.", + "case": "board_iteration", + "rules": "v2", + "input": { + "op": "range", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "C1" + } + ], + "fields": [ + { + "id": 1, + "name": "Sprint", + "type": "iter", + "start": "2024-02-20", + "days": 10 + } + ] + }, + "field": 1, + "ks": [ + 0, + 1 + ] + }, + "expected": [ + { + "index": 0, + "name": "Sprint 1", + "start": "2024-02-20", + "end": "2024-02-29", + "startMs": 1708387200000, + "endMs": 1709251200000 + }, + { + "index": 1, + "name": "Sprint 2", + "start": "2024-03-01", + "end": "2024-03-10", + "startMs": 1709251200000, + "endMs": 1710115200000 + } + ] +} diff --git a/forge-contracts/vectors/board_query__match_archive_and_state.json b/forge-contracts/vectors/board_query__match_archive_and_state.json new file mode 100644 index 000000000..c4a529de2 --- /dev/null +++ b/forge-contracts/vectors/board_query__match_archive_and_state.json @@ -0,0 +1,334 @@ +{ + "name": "match_archive_and_state", + "description": "Archived items are hidden unless the query has is:archived (then only they show); removed and off-board items never match; is:closed is closed or merged, is:unmerged open or closed; -is:archived is the default.", + "case": "board_query", + "rules": "v2", + "input": { + "op": "match", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + }, + { + "id": 6, + "name": "Story points", + "type": "num" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "me": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb", + "items": [ + { + "id": "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "number": 91, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791140400000, + "closedAt": null, + "title": "Crash on start", + "labels": [ + "bug" + ], + "assignees": [ + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v1.0", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "number": 12, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791144000000, + "closedAt": null, + "title": "Docs: exact phrase here", + "labels": [], + "assignees": [ + "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "number": 93, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "merged", + "createdAt": 1791147600000, + "closedAt": 1793016000000, + "title": "Refactor", + "labels": [], + "assignees": [], + "milestone": null, + "author": "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r" + }, + { + "id": "7NB8fAfBXV6XBGALr2V57fdVuyqsFqDewMRNxrm56e4u", + "number": 94, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791151200000, + "closedAt": 1791374400000, + "title": "Old crash", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "number": 95, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "Bob/Lib", + "kind": "issue", + "state": "open", + "createdAt": 1791154800000, + "closedAt": null, + "title": "Other repo thing", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7WCRJMQiTstFrcjagXwcLRophhHBSJyp5FAPesybdzjR", + "number": 96, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791158400000, + "closedAt": null, + "title": "Removed one", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g", + "number": 97, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791162000000, + "closedAt": null, + "title": "No fields", + "labels": [], + "assignees": [], + "milestone": "V1.0", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "col": 2, + "rank": null, + "f": "{\"1\":1,\"2\":5,\"3\":1,\"4\":\"2026-10-27\",\"5\":\"needs review soon\"}", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "col": 1, + "rank": null, + "f": "{\"1\":2,\"2\":3,\"3\":0,\"4\":\"2026-11-15\"}", + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "col": 4, + "rank": null, + "f": "{\"1\":1,\"2\":8,\"3\":2,\"4\":\"2026-10-01\"}", + "state": 0 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244804000, + "item": "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "col": 1, + "rank": null, + "f": "{\"2\":1.5,\"3\":1}", + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244805000, + "item": "7WCRJMQiTstFrcjagXwcLRophhHBSJyp5FAPesybdzjR", + "col": null, + "rank": null, + "f": null, + "state": 2 + } + ], + "texts": [ + "", + "is:archived", + "-is:archived", + "is:closed", + "is:unmerged", + "is:merged", + "is:pr", + "-is:issue" + ] + }, + "expected": [ + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g" + ], + [ + "7NB8fAfBXV6XBGALr2V57fdVuyqsFqDewMRNxrm56e4u" + ], + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g" + ], + [ + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje" + ], + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g" + ], + [ + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje" + ], + [ + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje" + ], + [ + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje" + ] + ] +} diff --git a/forge-contracts/vectors/board_query__match_before_first_iteration.json b/forge-contracts/vectors/board_query__match_before_first_iteration.json new file mode 100644 index 000000000..0973c7cae --- /dev/null +++ b/forge-contracts/vectors/board_query__match_before_first_iteration.json @@ -0,0 +1,308 @@ +{ + "name": "match_before_first_iteration", + "description": "Before an iteration field's first iteration there is no current or previous one, and the next is the first (index 0).", + "case": "board_query", + "rules": "v2", + "input": { + "op": "match", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + }, + { + "id": 6, + "name": "Story points", + "type": "num" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1791720000000, + "me": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb", + "items": [ + { + "id": "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "number": 91, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791140400000, + "closedAt": null, + "title": "Crash on start", + "labels": [ + "bug" + ], + "assignees": [ + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v1.0", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "number": 12, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791144000000, + "closedAt": null, + "title": "Docs: exact phrase here", + "labels": [], + "assignees": [ + "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "number": 93, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "merged", + "createdAt": 1791147600000, + "closedAt": 1793016000000, + "title": "Refactor", + "labels": [], + "assignees": [], + "milestone": null, + "author": "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r" + }, + { + "id": "7NB8fAfBXV6XBGALr2V57fdVuyqsFqDewMRNxrm56e4u", + "number": 94, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791151200000, + "closedAt": 1791374400000, + "title": "Old crash", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "number": 95, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "Bob/Lib", + "kind": "issue", + "state": "open", + "createdAt": 1791154800000, + "closedAt": null, + "title": "Other repo thing", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7WCRJMQiTstFrcjagXwcLRophhHBSJyp5FAPesybdzjR", + "number": 96, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791158400000, + "closedAt": null, + "title": "Removed one", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g", + "number": 97, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791162000000, + "closedAt": null, + "title": "No fields", + "labels": [], + "assignees": [], + "milestone": "V1.0", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "col": 2, + "rank": null, + "f": "{\"1\":1,\"2\":5,\"3\":1,\"4\":\"2026-10-27\",\"5\":\"needs review soon\"}", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "col": 1, + "rank": null, + "f": "{\"1\":2,\"2\":3,\"3\":0,\"4\":\"2026-11-15\"}", + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "col": 4, + "rank": null, + "f": "{\"1\":1,\"2\":8,\"3\":2,\"4\":\"2026-10-01\"}", + "state": 0 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244804000, + "item": "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "col": 1, + "rank": null, + "f": "{\"2\":1.5,\"3\":1}", + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244805000, + "item": "7WCRJMQiTstFrcjagXwcLRophhHBSJyp5FAPesybdzjR", + "col": null, + "rank": null, + "f": null, + "state": 2 + } + ], + "texts": [ + "iteration:@current", + "iteration:@next", + "iteration:@previous", + "-iteration:@previous" + ] + }, + "expected": [ + [], + [ + "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP" + ], + [], + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "7NB8fAfBXV6XBGALr2V57fdVuyqsFqDewMRNxrm56e4u", + "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g" + ] + ] +} diff --git a/forge-contracts/vectors/board_query__match_dates.json b/forge-contracts/vectors/board_query__match_dates.json new file mode 100644 index 000000000..2876f6c88 --- /dev/null +++ b/forge-contracts/vectors/board_query__match_dates.json @@ -0,0 +1,315 @@ +{ + "name": "match_dates", + "description": "Dates: <, >=, a range, and @today (now's UTC date, 2026-10-27).", + "case": "board_query", + "rules": "v2", + "input": { + "op": "match", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + }, + { + "id": 6, + "name": "Story points", + "type": "num" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "me": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb", + "items": [ + { + "id": "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "number": 91, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791140400000, + "closedAt": null, + "title": "Crash on start", + "labels": [ + "bug" + ], + "assignees": [ + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v1.0", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "number": 12, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791144000000, + "closedAt": null, + "title": "Docs: exact phrase here", + "labels": [], + "assignees": [ + "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "number": 93, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "merged", + "createdAt": 1791147600000, + "closedAt": 1793016000000, + "title": "Refactor", + "labels": [], + "assignees": [], + "milestone": null, + "author": "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r" + }, + { + "id": "7NB8fAfBXV6XBGALr2V57fdVuyqsFqDewMRNxrm56e4u", + "number": 94, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791151200000, + "closedAt": 1791374400000, + "title": "Old crash", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "number": 95, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "Bob/Lib", + "kind": "issue", + "state": "open", + "createdAt": 1791154800000, + "closedAt": null, + "title": "Other repo thing", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7WCRJMQiTstFrcjagXwcLRophhHBSJyp5FAPesybdzjR", + "number": 96, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791158400000, + "closedAt": null, + "title": "Removed one", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g", + "number": 97, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791162000000, + "closedAt": null, + "title": "No fields", + "labels": [], + "assignees": [], + "milestone": "V1.0", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "col": 2, + "rank": null, + "f": "{\"1\":1,\"2\":5,\"3\":1,\"4\":\"2026-10-27\",\"5\":\"needs review soon\"}", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "col": 1, + "rank": null, + "f": "{\"1\":2,\"2\":3,\"3\":0,\"4\":\"2026-11-15\"}", + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "col": 4, + "rank": null, + "f": "{\"1\":1,\"2\":8,\"3\":2,\"4\":\"2026-10-01\"}", + "state": 0 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244804000, + "item": "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "col": 1, + "rank": null, + "f": "{\"2\":1.5,\"3\":1}", + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244805000, + "item": "7WCRJMQiTstFrcjagXwcLRophhHBSJyp5FAPesybdzjR", + "col": null, + "rank": null, + "f": null, + "state": 2 + } + ], + "texts": [ + "target:<2026-11-01", + "target:@today", + "target:>=@today", + "target:2026-10-01..2026-10-27", + "no:target" + ] + }, + "expected": [ + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje" + ], + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58" + ], + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP" + ], + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje" + ], + [ + "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g" + ] + ] +} diff --git a/forge-contracts/vectors/board_query__match_fields.json b/forge-contracts/vectors/board_query__match_fields.json new file mode 100644 index 000000000..55c08e570 --- /dev/null +++ b/forge-contracts/vectors/board_query__match_fields.json @@ -0,0 +1,345 @@ +{ + "name": "match_fields", + "description": "Field qualifiers: a select option; numbers compared (a missing value never matches, so -priority:P0 matches items without one); ranges inclusive; no:; text fields contain (any case); status by column; no:status.", + "case": "board_query", + "rules": "v2", + "input": { + "op": "match", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + }, + { + "id": 6, + "name": "Story points", + "type": "num" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "me": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb", + "items": [ + { + "id": "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "number": 91, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791140400000, + "closedAt": null, + "title": "Crash on start", + "labels": [ + "bug" + ], + "assignees": [ + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v1.0", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "number": 12, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791144000000, + "closedAt": null, + "title": "Docs: exact phrase here", + "labels": [], + "assignees": [ + "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "number": 93, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "merged", + "createdAt": 1791147600000, + "closedAt": 1793016000000, + "title": "Refactor", + "labels": [], + "assignees": [], + "milestone": null, + "author": "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r" + }, + { + "id": "7NB8fAfBXV6XBGALr2V57fdVuyqsFqDewMRNxrm56e4u", + "number": 94, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791151200000, + "closedAt": 1791374400000, + "title": "Old crash", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "number": 95, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "Bob/Lib", + "kind": "issue", + "state": "open", + "createdAt": 1791154800000, + "closedAt": null, + "title": "Other repo thing", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7WCRJMQiTstFrcjagXwcLRophhHBSJyp5FAPesybdzjR", + "number": 96, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791158400000, + "closedAt": null, + "title": "Removed one", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g", + "number": 97, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791162000000, + "closedAt": null, + "title": "No fields", + "labels": [], + "assignees": [], + "milestone": "V1.0", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "col": 2, + "rank": null, + "f": "{\"1\":1,\"2\":5,\"3\":1,\"4\":\"2026-10-27\",\"5\":\"needs review soon\"}", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "col": 1, + "rank": null, + "f": "{\"1\":2,\"2\":3,\"3\":0,\"4\":\"2026-11-15\"}", + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "col": 4, + "rank": null, + "f": "{\"1\":1,\"2\":8,\"3\":2,\"4\":\"2026-10-01\"}", + "state": 0 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244804000, + "item": "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "col": 1, + "rank": null, + "f": "{\"2\":1.5,\"3\":1}", + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244805000, + "item": "7WCRJMQiTstFrcjagXwcLRophhHBSJyp5FAPesybdzjR", + "col": null, + "rank": null, + "f": null, + "state": 2 + } + ], + "texts": [ + "priority:P0", + "-priority:P0", + "estimate:>3", + "estimate:>=5", + "estimate:1..3", + "estimate:*..1.5", + "no:priority", + "no:estimate", + "notes:REVIEW", + "status:\"In progress\"", + "-status:Todo", + "no:status" + ] + }, + "expected": [ + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje" + ], + [ + "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g" + ], + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje" + ], + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje" + ], + [ + "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA" + ], + [ + "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA" + ], + [ + "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g" + ], + [ + "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g" + ], + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58" + ], + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58" + ], + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje" + ], + [] + ] +} diff --git a/forge-contracts/vectors/board_query__match_iterations.json b/forge-contracts/vectors/board_query__match_iterations.json new file mode 100644 index 000000000..43ef56077 --- /dev/null +++ b/forge-contracts/vectors/board_query__match_iterations.json @@ -0,0 +1,328 @@ +{ + "name": "match_iterations", + "description": "Iterations (start 2026-10-12, 14 days; now 2026-10-27 is in iteration index 1): @current, @next, @previous, <@current, by number (iteration:1 is index 0) and by name.", + "case": "board_query", + "rules": "v2", + "input": { + "op": "match", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + }, + { + "id": 6, + "name": "Story points", + "type": "num" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "me": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb", + "items": [ + { + "id": "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "number": 91, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791140400000, + "closedAt": null, + "title": "Crash on start", + "labels": [ + "bug" + ], + "assignees": [ + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v1.0", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "number": 12, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791144000000, + "closedAt": null, + "title": "Docs: exact phrase here", + "labels": [], + "assignees": [ + "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "number": 93, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "merged", + "createdAt": 1791147600000, + "closedAt": 1793016000000, + "title": "Refactor", + "labels": [], + "assignees": [], + "milestone": null, + "author": "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r" + }, + { + "id": "7NB8fAfBXV6XBGALr2V57fdVuyqsFqDewMRNxrm56e4u", + "number": 94, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791151200000, + "closedAt": 1791374400000, + "title": "Old crash", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "number": 95, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "Bob/Lib", + "kind": "issue", + "state": "open", + "createdAt": 1791154800000, + "closedAt": null, + "title": "Other repo thing", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7WCRJMQiTstFrcjagXwcLRophhHBSJyp5FAPesybdzjR", + "number": 96, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791158400000, + "closedAt": null, + "title": "Removed one", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g", + "number": 97, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791162000000, + "closedAt": null, + "title": "No fields", + "labels": [], + "assignees": [], + "milestone": "V1.0", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "col": 2, + "rank": null, + "f": "{\"1\":1,\"2\":5,\"3\":1,\"4\":\"2026-10-27\",\"5\":\"needs review soon\"}", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "col": 1, + "rank": null, + "f": "{\"1\":2,\"2\":3,\"3\":0,\"4\":\"2026-11-15\"}", + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "col": 4, + "rank": null, + "f": "{\"1\":1,\"2\":8,\"3\":2,\"4\":\"2026-10-01\"}", + "state": 0 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244804000, + "item": "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "col": 1, + "rank": null, + "f": "{\"2\":1.5,\"3\":1}", + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244805000, + "item": "7WCRJMQiTstFrcjagXwcLRophhHBSJyp5FAPesybdzjR", + "col": null, + "rank": null, + "f": null, + "state": 2 + } + ], + "texts": [ + "iteration:@current", + "iteration:@next", + "iteration:@previous", + "iteration:<@current", + "iteration:>=@current", + "iteration:1", + "iteration:\"iteration 3\"", + "-iteration:@current" + ] + }, + "expected": [ + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA" + ], + [ + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje" + ], + [ + "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP" + ], + [ + "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP" + ], + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA" + ], + [ + "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP" + ], + [ + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje" + ], + [ + "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g" + ] + ] +} diff --git a/forge-contracts/vectors/board_query__match_no_viewer.json b/forge-contracts/vectors/board_query__match_no_viewer.json new file mode 100644 index 000000000..045a6c7de --- /dev/null +++ b/forge-contracts/vectors/board_query__match_no_viewer.json @@ -0,0 +1,301 @@ +{ + "name": "match_no_viewer", + "description": "Without a viewer @me matches nobody (and -assignee:@me everybody).", + "case": "board_query", + "rules": "v2", + "input": { + "op": "match", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + }, + { + "id": 6, + "name": "Story points", + "type": "num" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "me": null, + "items": [ + { + "id": "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "number": 91, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791140400000, + "closedAt": null, + "title": "Crash on start", + "labels": [ + "bug" + ], + "assignees": [ + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v1.0", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "number": 12, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791144000000, + "closedAt": null, + "title": "Docs: exact phrase here", + "labels": [], + "assignees": [ + "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "number": 93, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "merged", + "createdAt": 1791147600000, + "closedAt": 1793016000000, + "title": "Refactor", + "labels": [], + "assignees": [], + "milestone": null, + "author": "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r" + }, + { + "id": "7NB8fAfBXV6XBGALr2V57fdVuyqsFqDewMRNxrm56e4u", + "number": 94, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791151200000, + "closedAt": 1791374400000, + "title": "Old crash", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "number": 95, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "Bob/Lib", + "kind": "issue", + "state": "open", + "createdAt": 1791154800000, + "closedAt": null, + "title": "Other repo thing", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7WCRJMQiTstFrcjagXwcLRophhHBSJyp5FAPesybdzjR", + "number": 96, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791158400000, + "closedAt": null, + "title": "Removed one", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g", + "number": 97, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791162000000, + "closedAt": null, + "title": "No fields", + "labels": [], + "assignees": [], + "milestone": "V1.0", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "col": 2, + "rank": null, + "f": "{\"1\":1,\"2\":5,\"3\":1,\"4\":\"2026-10-27\",\"5\":\"needs review soon\"}", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "col": 1, + "rank": null, + "f": "{\"1\":2,\"2\":3,\"3\":0,\"4\":\"2026-11-15\"}", + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "col": 4, + "rank": null, + "f": "{\"1\":1,\"2\":8,\"3\":2,\"4\":\"2026-10-01\"}", + "state": 0 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244804000, + "item": "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "col": 1, + "rank": null, + "f": "{\"2\":1.5,\"3\":1}", + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244805000, + "item": "7WCRJMQiTstFrcjagXwcLRophhHBSJyp5FAPesybdzjR", + "col": null, + "rank": null, + "f": null, + "state": 2 + } + ], + "texts": [ + "assignee:@me", + "-assignee:@me" + ] + }, + "expected": [ + [], + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g" + ] + ] +} diff --git a/forge-contracts/vectors/board_query__match_people_and_repo.json b/forge-contracts/vectors/board_query__match_people_and_repo.json new file mode 100644 index 000000000..a0bc39a83 --- /dev/null +++ b/forge-contracts/vectors/board_query__match_people_and_repo.json @@ -0,0 +1,363 @@ +{ + "name": "match_people_and_repo", + "description": "assignee:@me is the viewer (none without one), author:, no:assignee, milestone in any case, repo: by id or by a name the client resolved (`repos`), -repo; a name it did not resolve is reported and not applied, whatever the items' labels say.", + "case": "board_query", + "rules": "v2", + "input": { + "op": "match", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + }, + { + "id": 6, + "name": "Story points", + "type": "num" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "me": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb", + "items": [ + { + "id": "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "number": 91, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791140400000, + "closedAt": null, + "title": "Crash on start", + "labels": [ + "bug" + ], + "assignees": [ + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v1.0", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "number": 12, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791144000000, + "closedAt": null, + "title": "Docs: exact phrase here", + "labels": [], + "assignees": [ + "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "number": 93, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "merged", + "createdAt": 1791147600000, + "closedAt": 1793016000000, + "title": "Refactor", + "labels": [], + "assignees": [], + "milestone": null, + "author": "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r" + }, + { + "id": "7NB8fAfBXV6XBGALr2V57fdVuyqsFqDewMRNxrm56e4u", + "number": 94, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791151200000, + "closedAt": 1791374400000, + "title": "Old crash", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "number": 95, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "Bob/Lib", + "kind": "issue", + "state": "open", + "createdAt": 1791154800000, + "closedAt": null, + "title": "Other repo thing", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7WCRJMQiTstFrcjagXwcLRophhHBSJyp5FAPesybdzjR", + "number": 96, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791158400000, + "closedAt": null, + "title": "Removed one", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g", + "number": 97, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791162000000, + "closedAt": null, + "title": "No fields", + "labels": [], + "assignees": [], + "milestone": "V1.0", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "col": 2, + "rank": null, + "f": "{\"1\":1,\"2\":5,\"3\":1,\"4\":\"2026-10-27\",\"5\":\"needs review soon\"}", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "col": 1, + "rank": null, + "f": "{\"1\":2,\"2\":3,\"3\":0,\"4\":\"2026-11-15\"}", + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "col": 4, + "rank": null, + "f": "{\"1\":1,\"2\":8,\"3\":2,\"4\":\"2026-10-01\"}", + "state": 0 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244804000, + "item": "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "col": 1, + "rank": null, + "f": "{\"2\":1.5,\"3\":1}", + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244805000, + "item": "7WCRJMQiTstFrcjagXwcLRophhHBSJyp5FAPesybdzjR", + "col": null, + "rank": null, + "f": null, + "state": 2 + } + ], + "texts": [ + "assignee:@me", + "assignee:Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "author:Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "no:assignee", + "milestone:v1.0", + "repo:bob/lib", + "repo:EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "-repo:bob/lib", + "label:BUG", + "no:label", + "repo:Bob/Lib", + "-repo:nobody/none" + ], + "repos": { + "bob/lib": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx" + } + }, + "expected": [ + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP" + ], + [ + "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP" + ], + [ + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje" + ], + [ + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g" + ], + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g" + ], + [ + "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA" + ], + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g" + ], + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g" + ], + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58" + ], + [ + "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g" + ], + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g" + ], + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g" + ] + ] +} diff --git a/forge-contracts/vectors/board_query__match_text.json b/forge-contracts/vectors/board_query__match_text.json new file mode 100644 index 000000000..6b640e06a --- /dev/null +++ b/forge-contracts/vectors/board_query__match_text.json @@ -0,0 +1,319 @@ +{ + "name": "match_text", + "description": "Free text: title words (any case), a quoted phrase, #12 is the number only, a bare 12 the number or the title, -word excludes; an unresolved qualifier does not filter.", + "case": "board_query", + "rules": "v2", + "input": { + "op": "match", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + }, + { + "id": 6, + "name": "Story points", + "type": "num" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "me": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb", + "items": [ + { + "id": "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "number": 91, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791140400000, + "closedAt": null, + "title": "Crash on start", + "labels": [ + "bug" + ], + "assignees": [ + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v1.0", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "number": 12, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791144000000, + "closedAt": null, + "title": "Docs: exact phrase here", + "labels": [], + "assignees": [ + "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "number": 93, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "merged", + "createdAt": 1791147600000, + "closedAt": 1793016000000, + "title": "Refactor", + "labels": [], + "assignees": [], + "milestone": null, + "author": "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r" + }, + { + "id": "7NB8fAfBXV6XBGALr2V57fdVuyqsFqDewMRNxrm56e4u", + "number": 94, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791151200000, + "closedAt": 1791374400000, + "title": "Old crash", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "number": 95, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "Bob/Lib", + "kind": "issue", + "state": "open", + "createdAt": 1791154800000, + "closedAt": null, + "title": "Other repo thing", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7WCRJMQiTstFrcjagXwcLRophhHBSJyp5FAPesybdzjR", + "number": 96, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791158400000, + "closedAt": null, + "title": "Removed one", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7aD4cwnUw5H8CJ2Cbnfswotz6YzqXYrteC2tztarug4g", + "number": 97, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791162000000, + "closedAt": null, + "title": "No fields", + "labels": [], + "assignees": [], + "milestone": "V1.0", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58", + "col": 2, + "rank": null, + "f": "{\"1\":1,\"2\":5,\"3\":1,\"4\":\"2026-10-27\",\"5\":\"needs review soon\"}", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP", + "col": 1, + "rank": null, + "f": "{\"1\":2,\"2\":3,\"3\":0,\"4\":\"2026-11-15\"}", + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "7JAVLaHR4HheqasivmkoWHYLX88DAbLaNQYscr9opxje", + "col": 4, + "rank": null, + "f": "{\"1\":1,\"2\":8,\"3\":2,\"4\":\"2026-10-01\"}", + "state": 0 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244804000, + "item": "7SBmym2wzgVPWwSxmHDLj3ifJqZXM56jWJHtJsNLNKQA", + "col": 1, + "rank": null, + "f": "{\"2\":1.5,\"3\":1}", + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244805000, + "item": "7WCRJMQiTstFrcjagXwcLRophhHBSJyp5FAPesybdzjR", + "col": null, + "rank": null, + "f": null, + "state": 2 + } + ], + "texts": [ + "crash", + "\"exact phrase\"", + "#12", + "12", + "#91", + "crash -old", + "priority:P9 crash" + ] + }, + "expected": [ + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58" + ], + [ + "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP" + ], + [ + "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP" + ], + [ + "7E9r1yueb6JnVub71X2XtuTB8GQZ5MTVoTgNGqYYZHQP" + ], + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58" + ], + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58" + ], + [ + "7A9ChPXt7tuvAEJV6GJGHXN1jQgtz7aREWorvpwHHc58" + ] + ] +} diff --git a/forge-contracts/vectors/board_query__parse_board_qualifiers.json b/forge-contracts/vectors/board_query__parse_board_qualifiers.json new file mode 100644 index 000000000..9bececca3 --- /dev/null +++ b/forge-contracts/vectors/board_query__parse_board_qualifiers.json @@ -0,0 +1,287 @@ +{ + "name": "parse_board_qualifiers", + "description": "Board qualifiers: status by column name (any case, quoted), -status, no:status; a select field by option name; number comparisons (>3 >=3 <3 <=2.5 1..5 *..5 2..*); date comparisons and ranges, @today; iterations by @current/@next/@previous, number, or name; no:; text fields (has); a quoted field name with a space.", + "case": "board_query", + "rules": "v2", + "input": { + "op": "parse", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + }, + { + "id": 6, + "name": "Story points", + "type": "num" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "text": "status:\"in progress\" -status:Done no:status priority:p0 -Priority:P1 estimate:>3 estimate:>=3 estimate:<3 estimate:<=2.5 estimate:1..5 estimate:*..5 estimate:-2..* target:<2026-11-01 target:2026-10-01..2026-10-31 target:>=@today iteration:@current iteration:@NEXT iteration:@previous iteration:2 iteration:\"Iteration 3\" iteration:<@current no:priority notes:\"Needs Review\" \"story points\":>=8" + }, + "expected": { + "preds": [ + { + "k": "status", + "not": false, + "v": 2 + }, + { + "k": "status", + "not": true, + "v": 3 + }, + { + "k": "no", + "not": false, + "v": "status" + }, + { + "k": "field", + "not": false, + "f": 1, + "op": "eq", + "v": 1 + }, + { + "k": "field", + "not": true, + "f": 1, + "op": "eq", + "v": 2 + }, + { + "k": "field", + "not": false, + "f": 2, + "op": "gt", + "v": 3 + }, + { + "k": "field", + "not": false, + "f": 2, + "op": "ge", + "v": 3 + }, + { + "k": "field", + "not": false, + "f": 2, + "op": "lt", + "v": 3 + }, + { + "k": "field", + "not": false, + "f": 2, + "op": "le", + "v": 2.5 + }, + { + "k": "field", + "not": false, + "f": 2, + "op": "range", + "v": 1, + "v2": 5 + }, + { + "k": "field", + "not": false, + "f": 2, + "op": "le", + "v": 5 + }, + { + "k": "field", + "not": false, + "f": 2, + "op": "ge", + "v": -2 + }, + { + "k": "field", + "not": false, + "f": 4, + "op": "lt", + "v": "2026-11-01" + }, + { + "k": "field", + "not": false, + "f": 4, + "op": "range", + "v": "2026-10-01", + "v2": "2026-10-31" + }, + { + "k": "field", + "not": false, + "f": 4, + "op": "ge", + "v": "@today" + }, + { + "k": "field", + "not": false, + "f": 3, + "op": "eq", + "v": "@current" + }, + { + "k": "field", + "not": false, + "f": 3, + "op": "eq", + "v": "@next" + }, + { + "k": "field", + "not": false, + "f": 3, + "op": "eq", + "v": "@previous" + }, + { + "k": "field", + "not": false, + "f": 3, + "op": "eq", + "v": 1 + }, + { + "k": "field", + "not": false, + "f": 3, + "op": "eq", + "v": 2 + }, + { + "k": "field", + "not": false, + "f": 3, + "op": "lt", + "v": "@current" + }, + { + "k": "no", + "not": false, + "v": "f1" + }, + { + "k": "field", + "not": false, + "f": 5, + "op": "has", + "v": "needs review" + }, + { + "k": "field", + "not": false, + "f": 6, + "op": "ge", + "v": 8 + } + ], + "text": "", + "unresolved": [] + } +} diff --git a/forge-contracts/vectors/board_query__parse_issue_qualifiers.json b/forge-contracts/vectors/board_query__parse_issue_qualifiers.json new file mode 100644 index 000000000..6497f01b1 --- /dev/null +++ b/forge-contracts/vectors/board_query__parse_issue_qualifiers.json @@ -0,0 +1,183 @@ +{ + "name": "parse_issue_qualifiers", + "description": "The Issues tab's qualifiers in a board query: is:/state:, label (quoted), -label, no:, assignee:@me, author:, milestone (quoted), repo:, is:archived; keys in any case; the rest is free text (#12, -word).", + "case": "board_query", + "rules": "v2", + "input": { + "op": "parse", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + }, + { + "id": 6, + "name": "Story points", + "type": "num" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "text": "IS:Open -label:wontfix label:\"good first\" no:assignee assignee:@ME author:Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r milestone:\"v1.0\" repo:alice/forge state:merged is:archived -is:pr crash #12 -windows", + "repos": { + "alice/forge": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h" + } + }, + "expected": { + "preds": [ + { + "k": "is", + "not": false, + "v": "open" + }, + { + "k": "label", + "not": true, + "v": "wontfix" + }, + { + "k": "label", + "not": false, + "v": "good first" + }, + { + "k": "no", + "not": false, + "v": "assignee" + }, + { + "k": "assignee", + "not": false, + "v": "me" + }, + { + "k": "author", + "not": false, + "v": "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r" + }, + { + "k": "milestone", + "not": false, + "v": "v1.0" + }, + { + "k": "repo", + "not": false, + "v": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h" + }, + { + "k": "is", + "not": false, + "v": "merged" + }, + { + "k": "is", + "not": false, + "v": "archived" + }, + { + "k": "is", + "not": true, + "v": "pr" + } + ], + "text": "crash #12 -windows", + "unresolved": [] + } +} diff --git a/forge-contracts/vectors/board_query__parse_repo.json b/forge-contracts/vectors/board_query__parse_repo.json new file mode 100644 index 000000000..3d32e11b3 --- /dev/null +++ b/forge-contracts/vectors/board_query__parse_repo.json @@ -0,0 +1,156 @@ +{ + "name": "parse_repo", + "description": "repo: takes a repository id as typed, or a name the client resolved to one (`repos`, keyed by the name as typed and unquoted); a name it did not resolve, a resolution that is not an id, and an empty value are reported. Names are not matched in any case here: resolving (DPNS names, repo slugs) is the client's.", + "case": "board_query", + "rules": "v2", + "input": { + "op": "parse", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + }, + { + "id": 6, + "name": "Story points", + "type": "num" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "repos": { + "alice/forge": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "bob/lib": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "forge": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "odd/one": "not-an-id" + }, + "text": "repo:alice/forge -repo:\"bob/lib\" repo:EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx repo:nobody/none repo:forge Repo:Alice/Forge repo:odd/one repo:" + }, + "expected": { + "preds": [ + { + "k": "repo", + "not": false, + "v": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h" + }, + { + "k": "repo", + "not": true, + "v": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx" + }, + { + "k": "repo", + "not": false, + "v": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx" + }, + { + "k": "repo", + "not": false, + "v": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h" + } + ], + "text": "", + "unresolved": [ + "repo:nobody/none", + "Repo:Alice/Forge", + "repo:odd/one", + "repo:" + ] + } +} diff --git a/forge-contracts/vectors/board_query__parse_source.json b/forge-contracts/vectors/board_query__parse_source.json new file mode 100644 index 000000000..41f2e544c --- /dev/null +++ b/forge-contracts/vectors/board_query__parse_source.json @@ -0,0 +1,152 @@ +{ + "name": "parse_source", + "description": "A source's query keeps only what the item itself answers: status:, custom fields, no:status / no:, is:archived and @me are reported (a source is the same for every reader, before any card).", + "case": "board_query", + "rules": "v2", + "input": { + "op": "source", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + }, + { + "id": 6, + "name": "Story points", + "type": "num" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "text": "label:bug status:Todo priority:P0 no:priority no:status no:label assignee:@me author:Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r -is:archived is:open fix" + }, + "expected": { + "preds": [ + { + "k": "label", + "not": false, + "v": "bug" + }, + { + "k": "no", + "not": false, + "v": "label" + }, + { + "k": "author", + "not": false, + "v": "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r" + }, + { + "k": "is", + "not": false, + "v": "open" + } + ], + "text": "fix", + "unresolved": [ + "status:Todo", + "priority:P0", + "no:priority", + "no:status", + "assignee:@me", + "-is:archived" + ] + } +} diff --git a/forge-contracts/vectors/board_query__parse_unresolved.json b/forge-contracts/vectors/board_query__parse_unresolved.json new file mode 100644 index 000000000..2548ff411 --- /dev/null +++ b/forge-contracts/vectors/board_query__parse_unresolved.json @@ -0,0 +1,144 @@ +{ + "name": "parse_unresolved", + "description": "What names nothing on this board is reported, never searched as text: an unknown field, option or column, a value of the wrong shape, an empty value of a known key, a DPNS name (resolve it first), is:draft, -no: is applied (NOT). A key with nothing after the colon and a URL stay text.", + "case": "board_query", + "rules": "v2", + "input": { + "op": "parse", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + }, + { + "id": 6, + "name": "Story points", + "type": "num" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "text": "foo:bar priority:P9 status:Nope estimate:abc estimate:*..* estimate:1e3 iteration:0 target:2026-13-01 is:draft state:issue assignee:alice.dash label: -no:label note: https://example.com/x \"story pts\":3 plain" + }, + "expected": { + "preds": [ + { + "k": "no", + "not": true, + "v": "label" + } + ], + "text": "note: https://example.com/x plain", + "unresolved": [ + "foo:bar", + "priority:P9", + "status:Nope", + "estimate:abc", + "estimate:*..*", + "estimate:1e3", + "iteration:0", + "target:2026-13-01", + "is:draft", + "state:issue", + "assignee:alice.dash", + "label:", + "\"story pts\":3" + ] + } +} diff --git a/forge-contracts/vectors/board_query__repo_names.json b/forge-contracts/vectors/board_query__repo_names.json new file mode 100644 index 000000000..916c45eb5 --- /dev/null +++ b/forge-contracts/vectors/board_query__repo_names.json @@ -0,0 +1,35 @@ +{ + "name": "repo_names", + "description": "The names a query's repo: qualifiers type, as a client resolves them: unquoted, each once, in order; ids, empty values, URLs and other keys are left out.", + "case": "board_query", + "rules": "v2", + "input": { + "op": "names", + "texts": [ + "repo:alice/forge -repo:\"bob/lib\" repo:alice/forge label:x", + "repo:EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx repo:forge", + "Repo:Forge -REPO:x/y", + "repo: repo://host/path", + "crash repo:\"a b/c\"", + "status:Done" + ] + }, + "expected": [ + [ + "alice/forge", + "bob/lib" + ], + [ + "forge" + ], + [ + "Forge", + "x/y" + ], + [], + [ + "a b/c" + ], + [] + ] +} diff --git a/forge-contracts/vectors/board_rank__between.json b/forge-contracts/vectors/board_rank__between.json new file mode 100644 index 000000000..889933525 --- /dev/null +++ b/forge-contracts/vectors/board_rank__between.json @@ -0,0 +1,167 @@ +{ + "name": "between", + "description": "rankBetween(a, b): strictly between in byte order, never ending in 0, the midpoint of the free digits (\"\" is open at either end). Prefix pairs (V / V1, V1 / V11), neighbours with no digit between (A / B: one more digit), the top (z) and bottom (0) of the alphabet.", + "case": "board_rank", + "rules": "v2", + "input": { + "op": "between", + "pairs": [ + [ + "", + "" + ], + [ + null, + null + ], + [ + "", + "V" + ], + [ + "W", + "" + ], + [ + "A", + "C" + ], + [ + "A", + "B" + ], + [ + "Az", + "B" + ], + [ + "U", + "V1" + ], + [ + "V", + "V1" + ], + [ + "V", + "W" + ], + [ + "V1", + "V11" + ], + [ + "V1", + "V2" + ], + [ + "0", + "1" + ], + [ + "", + "1" + ], + [ + "", + "01" + ], + [ + "", + "001" + ], + [ + "z", + "" + ], + [ + "zz", + "" + ], + [ + "y", + "z" + ], + [ + "yz", + "z" + ], + [ + "F", + "F1" + ], + [ + "F", + "F01" + ] + ] + }, + "expected": [ + { + "rank": "V" + }, + { + "rank": "V" + }, + { + "rank": "F" + }, + { + "rank": "l" + }, + { + "rank": "B" + }, + { + "rank": "AV" + }, + { + "rank": "AzV" + }, + { + "rank": "V" + }, + { + "rank": "V0V" + }, + { + "rank": "VV" + }, + { + "rank": "V10V" + }, + { + "rank": "V1V" + }, + { + "rank": "0V" + }, + { + "rank": "0V" + }, + { + "rank": "00V" + }, + { + "rank": "000V" + }, + { + "rank": "zV" + }, + { + "rank": "zzV" + }, + { + "rank": "yV" + }, + { + "rank": "yzV" + }, + { + "rank": "F0V" + }, + { + "rank": "F00V" + } + ] +} diff --git a/forge-contracts/vectors/board_rank__between_implicit_bounds.json b/forge-contracts/vectors/board_rank__between_implicit_bounds.json new file mode 100644 index 000000000..94762fee0 --- /dev/null +++ b/forge-contracts/vectors/board_rank__between_implicit_bounds.json @@ -0,0 +1,55 @@ +{ + "name": "between_implicit_bounds", + "description": "Bounds that are implicit ranks (13 digits, may end in 0): between two sourced items of one block, between a card and a sourced item, and below / above one.", + "case": "board_rank", + "rules": "v2", + "input": { + "op": "between", + "pairs": [ + [ + "V0ABCDEFG1230", + "V0ABCDEFG1231" + ], + [ + "V0ABCDEFG1230", + "V0ABCDEFG1300" + ], + [ + "V0ABCDEFGzzz0", + "V0ABCDEFH0000" + ], + [ + "F", + "V0ABCDEFG1230" + ], + [ + "V0ABCDEFG1230", + "l" + ], + [ + "V0ABCDEFG1230", + "V0ABCDEFG12300V" + ] + ] + }, + "expected": [ + { + "rank": "V0ABCDEFG1230V" + }, + { + "rank": "V0ABCDEFG13" + }, + { + "rank": "V0ABCDEFH" + }, + { + "rank": "N" + }, + { + "rank": "d" + }, + { + "rank": "V0ABCDEFG12300F" + } + ] +} diff --git a/forge-contracts/vectors/board_rank__between_refused.json b/forge-contracts/vectors/board_rank__between_refused.json new file mode 100644 index 000000000..1937ce718 --- /dev/null +++ b/forge-contracts/vectors/board_rank__between_refused.json @@ -0,0 +1,111 @@ +{ + "name": "between_refused", + "description": "Refusals: the lower bound above the upper (order); equal bounds (two members dropped into one gap at once and wrote one rank) are re-rank; a bound that is not rank digits or over 63 (invalid), and no rank of at most 63 digits between (re-rank): b = a + 0…0 (V / V0, \"\" / 0) and a 63-digit lower bound with nothing above it in 63 digits.", + "case": "board_rank", + "rules": "v2", + "input": { + "op": "between", + "pairs": [ + [ + "B", + "A" + ], + [ + "A", + "A" + ], + [ + "V1", + "V" + ], + [ + "a-b", + "" + ], + [ + "", + "é" + ], + [ + "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV", + "" + ], + [ + "V", + "V0" + ], + [ + "V1", + "V100" + ], + [ + "", + "0" + ], + [ + "", + "000" + ], + [ + "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", + "" + ], + [ + "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", + "" + ], + [ + "", + "000000000000000000000000000000000000000000000000000000000000001" + ], + [ + "V0ABCDEFG1230", + "V0ABCDEFG1230" + ] + ] + }, + "expected": [ + { + "error": "order" + }, + { + "error": "re-rank" + }, + { + "error": "order" + }, + { + "error": "invalid" + }, + { + "error": "invalid" + }, + { + "error": "invalid" + }, + { + "error": "re-rank" + }, + { + "error": "re-rank" + }, + { + "error": "re-rank" + }, + { + "error": "re-rank" + }, + { + "error": "re-rank" + }, + { + "rank": "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzV" + }, + { + "error": "re-rank" + }, + { + "error": "re-rank" + } + ] +} diff --git a/forge-contracts/vectors/board_rank__bottom.json b/forge-contracts/vectors/board_rank__bottom.json new file mode 100644 index 000000000..63af66b56 --- /dev/null +++ b/forge-contracts/vectors/board_rank__bottom.json @@ -0,0 +1,45 @@ +{ + "name": "bottom", + "description": "bottomRank(last) = rankBetween(max(last, \"W\"), \"\"): below the column and the sourced pool, so later sourced items (V…) never pass it.", + "case": "board_rank", + "rules": "v2", + "input": { + "op": "bottom", + "lasts": [ + null, + "V", + "W", + "l", + "z", + "zz", + "V0ABCDEFG1230", + "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" + ] + }, + "expected": [ + { + "rank": "l" + }, + { + "rank": "l" + }, + { + "rank": "l" + }, + { + "rank": "s" + }, + { + "rank": "zV" + }, + { + "rank": "zzV" + }, + { + "rank": "l" + }, + { + "error": "re-rank" + } + ] +} diff --git a/forge-contracts/vectors/board_rank__implicit.json b/forge-contracts/vectors/board_rank__implicit.json new file mode 100644 index 000000000..43ebeffcc --- /dev/null +++ b/forge-contracts/vectors/board_rank__implicit.json @@ -0,0 +1,48 @@ +{ + "name": "implicit", + "description": "Implicit ranks: V + $createdAt in 8 base-62 digits + the first 3 bytes of the item $id (big-endian, mod 62^4) in 4. Items of one block (same $createdAt) differ by id; 0xFFFFFF wraps mod 62^4; leading zero bytes (base58 \"1…\"); a time past 62^8 clamps; an id that is not base58 reads as zero bytes.", + "case": "board_rank", + "rules": "v2", + "input": { + "op": "implicit", + "items": [ + { + "createdAt": 0, + "id": "1113eKEmP3gmGaNeoKSVoYwPpyfTmrmizMbi1TqGj2" + }, + { + "createdAt": 1793102400000, + "id": "4wBqjG7ot2Yh7rmZH2TnTTiNfnkjtVZAZBzCrpAzziV" + }, + { + "createdAt": 1793102400000, + "id": "4wC3PxcZmLQCWc587TrKavgTRYrW4VEZtLuPrrc4QAv" + }, + { + "createdAt": 1793102400000, + "id": "JEKNJMGgDzL9VWNzXbjVraMJri27JLwhwLkBfTRecuQw" + }, + { + "createdAt": 1793102400000, + "id": "112QabqpfPtBDgyDYU5suefhVfk1HR3Gs6i8bH6kHjz" + }, + { + "createdAt": 218340105584901, + "id": "R4rvZFbpBND34iiWXNcfHXyN9JwYSHUQgE354ead4zZ" + }, + { + "createdAt": 1793102400000, + "id": "not-base58-0OIl" + } + ] + }, + "expected": [ + "V000000000000", + "V0VZFavzc0HBL", + "V0VZFavzc0HBM", + "V0VZFavzc8OWF", + "V0VZFavzc0007", + "Vzzzzzzzz1h6s", + "V0VZFavzc0000" + ] +} diff --git a/forge-contracts/vectors/board_rank__rerank_empty.json b/forge-contracts/vectors/board_rank__rerank_empty.json new file mode 100644 index 000000000..fe780da02 --- /dev/null +++ b/forge-contracts/vectors/board_rank__rerank_empty.json @@ -0,0 +1,13 @@ +{ + "name": "rerank_empty", + "description": "rerank(0): no ranks.", + "case": "board_rank", + "rules": "v2", + "input": { + "op": "rerank", + "n": 0 + }, + "expected": { + "ranks": [] + } +} diff --git a/forge-contracts/vectors/board_rank__rerank_three.json b/forge-contracts/vectors/board_rank__rerank_three.json new file mode 100644 index 000000000..be78e79e7 --- /dev/null +++ b/forge-contracts/vectors/board_rank__rerank_three.json @@ -0,0 +1,17 @@ +{ + "name": "rerank_three", + "description": "rerank(3): k/4 of the way from 0 to V in 2 digits (31·62 = 1922 ≥ 62·4), trailing zeros dropped: all below the sourced pool.", + "case": "board_rank", + "rules": "v2", + "input": { + "op": "rerank", + "n": 3 + }, + "expected": { + "ranks": [ + "7k", + "FV", + "NF" + ] + } +} diff --git a/forge-contracts/vectors/board_rank__rerank_too_many.json b/forge-contracts/vectors/board_rank__rerank_too_many.json new file mode 100644 index 000000000..5f12aa473 --- /dev/null +++ b/forge-contracts/vectors/board_rank__rerank_too_many.json @@ -0,0 +1,13 @@ +{ + "name": "rerank_too_many", + "description": "rerank past 1 000 000 items is refused (invalid).", + "case": "board_rank", + "rules": "v2", + "input": { + "op": "rerank", + "n": 1000001 + }, + "expected": { + "error": "invalid" + } +} diff --git a/forge-contracts/vectors/board_rank__rerank_wide.json b/forge-contracts/vectors/board_rank__rerank_wide.json new file mode 100644 index 000000000..6bbbd3a79 --- /dev/null +++ b/forge-contracts/vectors/board_rank__rerank_wide.json @@ -0,0 +1,45 @@ +{ + "name": "rerank_wide", + "description": "rerank(31): 2 digits would leave under 62 ranks between neighbours (1922 < 62·32), so 3 digits.", + "case": "board_rank", + "rules": "v2", + "input": { + "op": "rerank", + "n": 31 + }, + "expected": { + "ranks": [ + "0y3", + "1w7", + "2uB", + "3sF", + "4qJ", + "5oN", + "6mR", + "7kV", + "8iY", + "9gc", + "Aeg", + "Bck", + "Cao", + "DYs", + "EWw", + "FV", + "GT3", + "HR7", + "IPB", + "JNF", + "KLJ", + "LJN", + "MHR", + "NFV", + "ODY", + "PBc", + "Q9g", + "R7k", + "S5o", + "T3s", + "U1w" + ] + } +} diff --git a/forge-contracts/vectors/board_rank__top.json b/forge-contracts/vectors/board_rank__top.json new file mode 100644 index 000000000..395ee5156 --- /dev/null +++ b/forge-contracts/vectors/board_rank__top.json @@ -0,0 +1,49 @@ +{ + "name": "top", + "description": "topRank(first) = rankBetween(\"\", min(first, \"V\")): above the column and the sourced pool; an empty column (null) as below \"V\".", + "case": "board_rank", + "rules": "v2", + "input": { + "op": "top", + "firsts": [ + null, + "V", + "W", + "z", + "F", + "5", + "1", + "01", + "V0ABCDEFG1230" + ] + }, + "expected": [ + { + "rank": "F" + }, + { + "rank": "F" + }, + { + "rank": "F" + }, + { + "rank": "F" + }, + { + "rank": "7" + }, + { + "rank": "2" + }, + { + "rank": "0V" + }, + { + "rank": "00V" + }, + { + "rank": "F" + } + ] +} diff --git a/forge-contracts/vectors/board_spec__default_template.json b/forge-contracts/vectors/board_spec__default_template.json new file mode 100644 index 000000000..160ae5452 --- /dev/null +++ b/forge-contracts/vectors/board_spec__default_template.json @@ -0,0 +1,14 @@ +{ + "name": "default_template", + "description": "The new-board template (§2): Todo / In progress / Done, Done = done column, default = Todo, the home repo's issues and PRs, Priority P0-P3 + Estimate + a 14-day Iteration from the Monday of the creation week (2026-10-27 is a Tuesday: 2026-10-26), Board / Table / Roadmap views, auto-archive 14 days; canonical JSON.", + "case": "board_spec", + "rules": "v2", + "input": { + "op": "default", + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000 + }, + "expected": { + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"In progress\"},{\"id\":3,\"name\":\"Done\"}],\"def\":1,\"done\":3,\"sources\":[{\"r\":\"EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h\",\"k\":\"a\"}],\"fields\":[{\"id\":1,\"name\":\"Priority\",\"type\":\"sel\",\"options\":[{\"id\":1,\"name\":\"P0\",\"color\":\"#d1242f\"},{\"id\":2,\"name\":\"P1\",\"color\":\"#fb8f44\"},{\"id\":3,\"name\":\"P2\",\"color\":\"#d4a72c\"},{\"id\":4,\"name\":\"P3\",\"color\":\"#8c959f\"}]},{\"id\":2,\"name\":\"Estimate\",\"type\":\"num\"},{\"id\":3,\"name\":\"Iteration\",\"type\":\"iter\",\"start\":\"2026-10-26\",\"days\":14}],\"views\":[{\"id\":1,\"name\":\"Board\",\"layout\":\"board\"},{\"id\":2,\"name\":\"Table\",\"layout\":\"table\",\"cols\":[\"title\",\"status\",\"assignees\",\"f1\",\"f2\",\"f3\"]},{\"id\":3,\"name\":\"Roadmap\",\"layout\":\"roadmap\",\"date\":[3]}],\"arch\":14}" + } +} diff --git a/forge-contracts/vectors/board_spec__parse_canonical.json b/forge-contracts/vectors/board_spec__parse_canonical.json new file mode 100644 index 000000000..ea3210deb --- /dev/null +++ b/forge-contracts/vectors/board_spec__parse_canonical.json @@ -0,0 +1,61 @@ +{ + "name": "parse_canonical", + "description": "A spec in any key order, with white space, an unknown key (tolerated, dropped), defaults written out and 1.0 for an id, reads back as canonical JSON: the declared key order, defaults (def/done/arch 0, empty q, empty lists) omitted.", + "case": "board_spec", + "rules": "v2", + "input": { + "op": "parse", + "cases": [ + { + "name": "scrambled", + "json": "{ \"arch\": 0, \"future\": {\"x\": 1}, \"views\": [{\"q\": \"\", \"layout\": \"table\", \"name\": \"T\", \"id\": 1.0, \"sort\": \"-f1\", \"cols\": [\"title\", \"f1\"]}],\n \"fields\": [{\"type\": \"num\", \"name\": \"Estimate\", \"id\": 1}], \"sources\": [], \"done\": 2, \"def\": 0,\n \"columns\": [{\"wip\": 3, \"name\": \"Todo\", \"id\": 1, \"color\": \"#AbCdEf\"}, {\"name\": \"Done\", \"id\": 2}], \"v\": 1 }" + }, + { + "name": "minimal", + "json": "{\"v\":1,\"columns\":[{\"id\":7,\"name\":\"Only\"}]}" + }, + { + "name": "source_defaults", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"sources\":[{\"k\":\"i\",\"q\":\"\"},{\"k\":\"p\",\"r\":\"EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx\",\"q\":\"label:bug\"}]}" + }, + { + "name": "unicode_names", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀\"},{\"id\":2,\"name\":\"Ünïcødé\"}]}" + }, + { + "name": "desc", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"desc\":\"Line one\\nline \\\"two\\\"\"}" + }, + { + "name": "views_all_keys", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"fields\":[{\"id\":1,\"name\":\"Pri\",\"type\":\"sel\",\"options\":[{\"id\":1,\"name\":\"High\",\"color\":\"#ff0000\"}]},{\"id\":2,\"name\":\"Start\",\"type\":\"date\"},{\"id\":3,\"name\":\"End\",\"type\":\"date\"},{\"id\":4,\"name\":\"Sprint\",\"type\":\"iter\",\"start\":\"2026-01-05\",\"days\":7}],\"views\":[{\"id\":1,\"name\":\"B\",\"layout\":\"board\",\"group\":\"f1\",\"lane\":\"assignee\",\"q\":\"is:open\"},{\"id\":2,\"name\":\"R\",\"layout\":\"roadmap\",\"date\":[2,3]},{\"id\":3,\"name\":\"S\",\"layout\":\"roadmap\",\"date\":[4],\"group\":\"f4\"},{\"id\":4,\"name\":\"T\",\"layout\":\"table\",\"group\":\"milestone\",\"lane\":\"f4\",\"sort\":\"created\"}]}" + } + ] + }, + "expected": [ + { + "name": "scrambled", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\",\"color\":\"#AbCdEf\",\"wip\":3},{\"id\":2,\"name\":\"Done\"}],\"done\":2,\"fields\":[{\"id\":1,\"name\":\"Estimate\",\"type\":\"num\"}],\"views\":[{\"id\":1,\"name\":\"T\",\"layout\":\"table\",\"sort\":\"-f1\",\"cols\":[\"title\",\"f1\"]}]}" + }, + { + "name": "minimal", + "json": "{\"v\":1,\"columns\":[{\"id\":7,\"name\":\"Only\"}]}" + }, + { + "name": "source_defaults", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"sources\":[{\"k\":\"i\"},{\"r\":\"EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx\",\"k\":\"p\",\"q\":\"label:bug\"}]}" + }, + { + "name": "unicode_names", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀\"},{\"id\":2,\"name\":\"Ünïcødé\"}]}" + }, + { + "name": "desc", + "json": "{\"v\":1,\"desc\":\"Line one\\nline \\\"two\\\"\",\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}]}" + }, + { + "name": "views_all_keys", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"fields\":[{\"id\":1,\"name\":\"Pri\",\"type\":\"sel\",\"options\":[{\"id\":1,\"name\":\"High\",\"color\":\"#ff0000\"}]},{\"id\":2,\"name\":\"Start\",\"type\":\"date\"},{\"id\":3,\"name\":\"End\",\"type\":\"date\"},{\"id\":4,\"name\":\"Sprint\",\"type\":\"iter\",\"start\":\"2026-01-05\",\"days\":7}],\"views\":[{\"id\":1,\"name\":\"B\",\"layout\":\"board\",\"q\":\"is:open\",\"group\":\"f1\",\"lane\":\"assignee\"},{\"id\":2,\"name\":\"R\",\"layout\":\"roadmap\",\"date\":[2,3]},{\"id\":3,\"name\":\"S\",\"layout\":\"roadmap\",\"group\":\"f4\",\"date\":[4]},{\"id\":4,\"name\":\"T\",\"layout\":\"table\",\"group\":\"milestone\",\"lane\":\"f4\",\"sort\":\"created\"}]}" + } + ] +} diff --git a/forge-contracts/vectors/board_spec__parse_refused.json b/forge-contracts/vectors/board_spec__parse_refused.json new file mode 100644 index 000000000..ef46a057f --- /dev/null +++ b/forge-contracts/vectors/board_spec__parse_refused.json @@ -0,0 +1,501 @@ +{ + "name": "parse_refused", + "description": "Every refusal names the first problem in the canonical key order: not JSON / not an object (json), v not 1 (version), over 4096 bytes (size), a list over its limit (columns, fields, sources, views), a malformed or repeated entry (an id, or a name in any letter case) (column, field, options, source, view), a dangling def / done, arch, desc.", + "case": "board_spec", + "rules": "v2", + "input": { + "op": "parse", + "cases": [ + { + "name": "not_json", + "json": "{\"v\":1," + }, + { + "name": "array", + "json": "[1]" + }, + { + "name": "version_2", + "json": "{\"v\":2,\"columns\":[{\"id\":1,\"name\":\"C1\"}]}" + }, + { + "name": "version_missing", + "json": "{\"columns\":[{\"id\":1,\"name\":\"C1\"}]}" + }, + { + "name": "oversize", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"desc\":\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\"views\":[{\"id\":1,\"name\":\"V\",\"layout\":\"table\",\"q\":\"yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\"}],\"sources\":[{\"k\":\"a\",\"q\":\"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"},{\"k\":\"a\",\"q\":\"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"},{\"k\":\"a\",\"q\":\"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"},{\"k\":\"a\",\"q\":\"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"},{\"k\":\"a\",\"q\":\"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"}]}" + }, + { + "name": "no_columns", + "json": "{\"v\":1,\"columns\":[]}" + }, + { + "name": "columns_21", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"C1\"},{\"id\":2,\"name\":\"C2\"},{\"id\":3,\"name\":\"C3\"},{\"id\":4,\"name\":\"C4\"},{\"id\":5,\"name\":\"C5\"},{\"id\":6,\"name\":\"C6\"},{\"id\":7,\"name\":\"C7\"},{\"id\":8,\"name\":\"C8\"},{\"id\":9,\"name\":\"C9\"},{\"id\":10,\"name\":\"C10\"},{\"id\":11,\"name\":\"C11\"},{\"id\":12,\"name\":\"C12\"},{\"id\":13,\"name\":\"C13\"},{\"id\":14,\"name\":\"C14\"},{\"id\":15,\"name\":\"C15\"},{\"id\":16,\"name\":\"C16\"},{\"id\":17,\"name\":\"C17\"},{\"id\":18,\"name\":\"C18\"},{\"id\":19,\"name\":\"C19\"},{\"id\":20,\"name\":\"C20\"},{\"id\":21,\"name\":\"C21\"}]}" + }, + { + "name": "columns_20", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"C1\"},{\"id\":2,\"name\":\"C2\"},{\"id\":3,\"name\":\"C3\"},{\"id\":4,\"name\":\"C4\"},{\"id\":5,\"name\":\"C5\"},{\"id\":6,\"name\":\"C6\"},{\"id\":7,\"name\":\"C7\"},{\"id\":8,\"name\":\"C8\"},{\"id\":9,\"name\":\"C9\"},{\"id\":10,\"name\":\"C10\"},{\"id\":11,\"name\":\"C11\"},{\"id\":12,\"name\":\"C12\"},{\"id\":13,\"name\":\"C13\"},{\"id\":14,\"name\":\"C14\"},{\"id\":15,\"name\":\"C15\"},{\"id\":16,\"name\":\"C16\"},{\"id\":17,\"name\":\"C17\"},{\"id\":18,\"name\":\"C18\"},{\"id\":19,\"name\":\"C19\"},{\"id\":20,\"name\":\"C20\"}]}" + }, + { + "name": "column_id_0", + "json": "{\"v\":1,\"columns\":[{\"id\":0,\"name\":\"C0\"}]}" + }, + { + "name": "column_id_256", + "json": "{\"v\":1,\"columns\":[{\"id\":256,\"name\":\"C256\"}]}" + }, + { + "name": "column_id_fraction", + "json": "{\"v\":1,\"columns\":[{\"id\":1.5,\"name\":\"C1.5\"}]}" + }, + { + "name": "column_id_repeated", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"A\"},{\"id\":1,\"name\":\"B\"}]}" + }, + { + "name": "column_name_repeated_case", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"TODO\"}]}" + }, + { + "name": "column_name_quote", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"say \\\"hi\\\"\"}]}" + }, + { + "name": "column_name_leading_space", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\" Todo\"}]}" + }, + { + "name": "column_name_nbsp_end", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo \"}]}" + }, + { + "name": "column_name_control", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"To\\u0007do\"}]}" + }, + { + "name": "column_name_64", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀\"}]}" + }, + { + "name": "column_name_empty", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"\"}]}" + }, + { + "name": "column_color", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"A\",\"color\":\"red\"}]}" + }, + { + "name": "column_color_null", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"A\",\"color\":null}]}" + }, + { + "name": "column_wip_0", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"A\",\"wip\":0}]}" + }, + { + "name": "def_missing_column", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"def\":9}" + }, + { + "name": "done_missing_column", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"done\":9}" + }, + { + "name": "done_string", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"done\":\"2\"}" + }, + { + "name": "sources_6", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"sources\":[{\"k\":\"a\"},{\"k\":\"a\"},{\"k\":\"a\"},{\"k\":\"a\"},{\"k\":\"a\"},{\"k\":\"a\"}]}" + }, + { + "name": "source_kind", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"sources\":[{\"k\":\"x\"}]}" + }, + { + "name": "source_repo_not_id", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"sources\":[{\"k\":\"a\",\"r\":\"alice/forge\"}]}" + }, + { + "name": "source_query_513", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"sources\":[{\"k\":\"a\",\"q\":\"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\"}]}" + }, + { + "name": "fields_13", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"fields\":[{\"id\":1,\"name\":\"F0\",\"type\":\"num\"},{\"id\":2,\"name\":\"F1\",\"type\":\"num\"},{\"id\":3,\"name\":\"F2\",\"type\":\"num\"},{\"id\":4,\"name\":\"F3\",\"type\":\"num\"},{\"id\":5,\"name\":\"F4\",\"type\":\"num\"},{\"id\":6,\"name\":\"F5\",\"type\":\"num\"},{\"id\":7,\"name\":\"F6\",\"type\":\"num\"},{\"id\":8,\"name\":\"F7\",\"type\":\"num\"},{\"id\":9,\"name\":\"F8\",\"type\":\"num\"},{\"id\":10,\"name\":\"F9\",\"type\":\"num\"},{\"id\":11,\"name\":\"F10\",\"type\":\"num\"},{\"id\":12,\"name\":\"F11\",\"type\":\"num\"},{\"id\":13,\"name\":\"F12\",\"type\":\"num\"}]}" + }, + { + "name": "field_reserved_status", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"fields\":[{\"id\":1,\"name\":\"Status\",\"type\":\"sel\",\"options\":[]}]}" + }, + { + "name": "field_reserved_labels", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"fields\":[{\"id\":1,\"name\":\"labels\",\"type\":\"text\"}]}" + }, + { + "name": "field_name_colon", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"fields\":[{\"id\":1,\"name\":\"a:b\",\"type\":\"text\"}]}" + }, + { + "name": "field_name_dash", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"fields\":[{\"id\":1,\"name\":\"-x\",\"type\":\"text\"}]}" + }, + { + "name": "field_type", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"fields\":[{\"id\":1,\"name\":\"X\",\"type\":\"multi\"}]}" + }, + { + "name": "field_options_on_num", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"fields\":[{\"id\":1,\"name\":\"X\",\"type\":\"num\",\"options\":[]}]}" + }, + { + "name": "field_sel_without_options", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"fields\":[{\"id\":1,\"name\":\"X\",\"type\":\"sel\"}]}" + }, + { + "name": "field_start_on_date", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"fields\":[{\"id\":1,\"name\":\"X\",\"type\":\"date\",\"start\":\"2026-01-01\"}]}" + }, + { + "name": "field_repeated_name", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"fields\":[{\"id\":1,\"name\":\"Pts\",\"type\":\"num\"},{\"id\":2,\"name\":\"pts\",\"type\":\"text\"}]}" + }, + { + "name": "options_31", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"fields\":[{\"id\":1,\"name\":\"X\",\"type\":\"sel\",\"options\":[{\"id\":1,\"name\":\"o0\"},{\"id\":2,\"name\":\"o1\"},{\"id\":3,\"name\":\"o2\"},{\"id\":4,\"name\":\"o3\"},{\"id\":5,\"name\":\"o4\"},{\"id\":6,\"name\":\"o5\"},{\"id\":7,\"name\":\"o6\"},{\"id\":8,\"name\":\"o7\"},{\"id\":9,\"name\":\"o8\"},{\"id\":10,\"name\":\"o9\"},{\"id\":11,\"name\":\"o10\"},{\"id\":12,\"name\":\"o11\"},{\"id\":13,\"name\":\"o12\"},{\"id\":14,\"name\":\"o13\"},{\"id\":15,\"name\":\"o14\"},{\"id\":16,\"name\":\"o15\"},{\"id\":17,\"name\":\"o16\"},{\"id\":18,\"name\":\"o17\"},{\"id\":19,\"name\":\"o18\"},{\"id\":20,\"name\":\"o19\"},{\"id\":21,\"name\":\"o20\"},{\"id\":22,\"name\":\"o21\"},{\"id\":23,\"name\":\"o22\"},{\"id\":24,\"name\":\"o23\"},{\"id\":25,\"name\":\"o24\"},{\"id\":26,\"name\":\"o25\"},{\"id\":27,\"name\":\"o26\"},{\"id\":28,\"name\":\"o27\"},{\"id\":29,\"name\":\"o28\"},{\"id\":30,\"name\":\"o29\"},{\"id\":31,\"name\":\"o30\"}]}]}" + }, + { + "name": "options_repeated", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"fields\":[{\"id\":1,\"name\":\"X\",\"type\":\"sel\",\"options\":[{\"id\":1,\"name\":\"a\"},{\"id\":2,\"name\":\"A\"}]}]}" + }, + { + "name": "options_0_ok", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"fields\":[{\"id\":1,\"name\":\"X\",\"type\":\"sel\",\"options\":[]}]}" + }, + { + "name": "iter_no_start", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"fields\":[{\"id\":1,\"name\":\"It\",\"type\":\"iter\",\"days\":14}]}" + }, + { + "name": "iter_days_91", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"fields\":[{\"id\":1,\"name\":\"It\",\"type\":\"iter\",\"start\":\"2026-01-05\",\"days\":91}]}" + }, + { + "name": "iter_start_feb_30", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"fields\":[{\"id\":1,\"name\":\"It\",\"type\":\"iter\",\"start\":\"2026-02-30\",\"days\":14}]}" + }, + { + "name": "views_9", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"views\":[{\"id\":1,\"name\":\"V0\",\"layout\":\"table\"},{\"id\":2,\"name\":\"V1\",\"layout\":\"table\"},{\"id\":3,\"name\":\"V2\",\"layout\":\"table\"},{\"id\":4,\"name\":\"V3\",\"layout\":\"table\"},{\"id\":5,\"name\":\"V4\",\"layout\":\"table\"},{\"id\":6,\"name\":\"V5\",\"layout\":\"table\"},{\"id\":7,\"name\":\"V6\",\"layout\":\"table\"},{\"id\":8,\"name\":\"V7\",\"layout\":\"table\"},{\"id\":9,\"name\":\"V8\",\"layout\":\"table\"}]}" + }, + { + "name": "view_layout", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"views\":[{\"id\":1,\"name\":\"V\",\"layout\":\"kanban\"}]}" + }, + { + "name": "view_board_group_assignee", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"views\":[{\"id\":1,\"name\":\"V\",\"layout\":\"board\",\"group\":\"assignee\"}]}" + }, + { + "name": "view_lane_is_group", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"views\":[{\"id\":1,\"name\":\"V\",\"layout\":\"table\",\"group\":\"label\",\"lane\":\"label\"}]}" + }, + { + "name": "view_lane_status", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"views\":[{\"id\":1,\"name\":\"V\",\"layout\":\"board\",\"lane\":\"status\"}]}" + }, + { + "name": "view_group_num_field", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"fields\":[{\"id\":1,\"name\":\"E\",\"type\":\"num\"}],\"views\":[{\"id\":1,\"name\":\"V\",\"layout\":\"table\",\"group\":\"f1\"}]}" + }, + { + "name": "view_sort_unknown", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"views\":[{\"id\":1,\"name\":\"V\",\"layout\":\"table\",\"sort\":\"priority\"}]}" + }, + { + "name": "view_sort_missing_field", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"views\":[{\"id\":1,\"name\":\"V\",\"layout\":\"table\",\"sort\":\"-f9\"}]}" + }, + { + "name": "view_cols_repeated", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"views\":[{\"id\":1,\"name\":\"V\",\"layout\":\"table\",\"cols\":[\"title\",\"title\"]}]}" + }, + { + "name": "view_cols_f01", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"fields\":[{\"id\":1,\"name\":\"E\",\"type\":\"num\"}],\"views\":[{\"id\":1,\"name\":\"V\",\"layout\":\"table\",\"cols\":[\"f01\"]}]}" + }, + { + "name": "view_date_num_field", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"fields\":[{\"id\":1,\"name\":\"E\",\"type\":\"num\"}],\"views\":[{\"id\":1,\"name\":\"V\",\"layout\":\"roadmap\",\"date\":[1]}]}" + }, + { + "name": "view_repeated_name", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"views\":[{\"id\":1,\"name\":\"V\",\"layout\":\"table\"},{\"id\":2,\"name\":\"v\",\"layout\":\"board\"}]}" + }, + { + "name": "arch_3651", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"arch\":3651}" + }, + { + "name": "desc_type", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"desc\":5}" + }, + { + "name": "desc_1025", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"desc\":\"ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"}" + }, + { + "name": "view_date_same_field", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"fields\":[{\"id\":1,\"name\":\"Start\",\"type\":\"date\"}],\"views\":[{\"id\":1,\"name\":\"R\",\"layout\":\"roadmap\",\"date\":[1,1]}]}" + } + ] + }, + "expected": [ + { + "name": "not_json", + "error": "json" + }, + { + "name": "array", + "error": "json" + }, + { + "name": "version_2", + "error": "version" + }, + { + "name": "version_missing", + "error": "version" + }, + { + "name": "oversize", + "error": "size" + }, + { + "name": "no_columns", + "error": "columns" + }, + { + "name": "columns_21", + "error": "columns" + }, + { + "name": "columns_20", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"C1\"},{\"id\":2,\"name\":\"C2\"},{\"id\":3,\"name\":\"C3\"},{\"id\":4,\"name\":\"C4\"},{\"id\":5,\"name\":\"C5\"},{\"id\":6,\"name\":\"C6\"},{\"id\":7,\"name\":\"C7\"},{\"id\":8,\"name\":\"C8\"},{\"id\":9,\"name\":\"C9\"},{\"id\":10,\"name\":\"C10\"},{\"id\":11,\"name\":\"C11\"},{\"id\":12,\"name\":\"C12\"},{\"id\":13,\"name\":\"C13\"},{\"id\":14,\"name\":\"C14\"},{\"id\":15,\"name\":\"C15\"},{\"id\":16,\"name\":\"C16\"},{\"id\":17,\"name\":\"C17\"},{\"id\":18,\"name\":\"C18\"},{\"id\":19,\"name\":\"C19\"},{\"id\":20,\"name\":\"C20\"}]}" + }, + { + "name": "column_id_0", + "error": "column" + }, + { + "name": "column_id_256", + "error": "column" + }, + { + "name": "column_id_fraction", + "error": "column" + }, + { + "name": "column_id_repeated", + "error": "column" + }, + { + "name": "column_name_repeated_case", + "error": "column" + }, + { + "name": "column_name_quote", + "error": "column" + }, + { + "name": "column_name_leading_space", + "error": "column" + }, + { + "name": "column_name_nbsp_end", + "error": "column" + }, + { + "name": "column_name_control", + "error": "column" + }, + { + "name": "column_name_64", + "error": "column" + }, + { + "name": "column_name_empty", + "error": "column" + }, + { + "name": "column_color", + "error": "column" + }, + { + "name": "column_color_null", + "error": "column" + }, + { + "name": "column_wip_0", + "error": "column" + }, + { + "name": "def_missing_column", + "error": "def" + }, + { + "name": "done_missing_column", + "error": "done" + }, + { + "name": "done_string", + "error": "done" + }, + { + "name": "sources_6", + "error": "sources" + }, + { + "name": "source_kind", + "error": "source" + }, + { + "name": "source_repo_not_id", + "error": "source" + }, + { + "name": "source_query_513", + "error": "source" + }, + { + "name": "fields_13", + "error": "fields" + }, + { + "name": "field_reserved_status", + "error": "field" + }, + { + "name": "field_reserved_labels", + "error": "field" + }, + { + "name": "field_name_colon", + "error": "field" + }, + { + "name": "field_name_dash", + "error": "field" + }, + { + "name": "field_type", + "error": "field" + }, + { + "name": "field_options_on_num", + "error": "field" + }, + { + "name": "field_sel_without_options", + "error": "field" + }, + { + "name": "field_start_on_date", + "error": "field" + }, + { + "name": "field_repeated_name", + "error": "field" + }, + { + "name": "options_31", + "error": "options" + }, + { + "name": "options_repeated", + "error": "options" + }, + { + "name": "options_0_ok", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"Done\"}],\"fields\":[{\"id\":1,\"name\":\"X\",\"type\":\"sel\",\"options\":[]}]}" + }, + { + "name": "iter_no_start", + "error": "field" + }, + { + "name": "iter_days_91", + "error": "field" + }, + { + "name": "iter_start_feb_30", + "error": "field" + }, + { + "name": "views_9", + "error": "views" + }, + { + "name": "view_layout", + "error": "view" + }, + { + "name": "view_board_group_assignee", + "error": "view" + }, + { + "name": "view_lane_is_group", + "error": "view" + }, + { + "name": "view_lane_status", + "error": "view" + }, + { + "name": "view_group_num_field", + "error": "view" + }, + { + "name": "view_sort_unknown", + "error": "view" + }, + { + "name": "view_sort_missing_field", + "error": "view" + }, + { + "name": "view_cols_repeated", + "error": "view" + }, + { + "name": "view_cols_f01", + "error": "view" + }, + { + "name": "view_date_num_field", + "error": "view" + }, + { + "name": "view_repeated_name", + "error": "view" + }, + { + "name": "arch_3651", + "error": "arch" + }, + { + "name": "desc_type", + "error": "desc" + }, + { + "name": "desc_1025", + "error": "desc" + }, + { + "name": "view_date_same_field", + "error": "view" + } + ] +} diff --git a/forge-contracts/vectors/board_spec__parse_serde_refusals.json b/forge-contracts/vectors/board_spec__parse_serde_refusals.json new file mode 100644 index 000000000..29b278e3c --- /dev/null +++ b/forge-contracts/vectors/board_spec__parse_serde_refusals.json @@ -0,0 +1,85 @@ +{ + "name": "parse_serde_refusals", + "description": "What forge-core's JSON reader (serde_json) refuses, the web refuses too, anywhere in the spec (an unknown key included): an unpaired surrogate escape, a number out of range (JavaScript would read 1e400 as Infinity), nesting past 127 levels. 127 levels read; an empty desc is none.", + "case": "board_spec", + "rules": "v2", + "input": { + "op": "parse", + "cases": [ + { + "name": "lone_surrogate_unknown_key", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"A\"}],\"x\":\"\\ud800\"}" + }, + { + "name": "lone_trailing_surrogate_name", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"a\\udc00\"}]}" + }, + { + "name": "lone_surrogate_desc", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"A\"}],\"desc\":\"\\ud800x\"}" + }, + { + "name": "surrogate_pair_ok", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"A\"}],\"desc\":\"\\ud83d\\ude80\"}" + }, + { + "name": "number_out_of_range", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"A\"}],\"x\":1e400}" + }, + { + "name": "arch_out_of_range", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"A\"}],\"arch\":-1e400}" + }, + { + "name": "depth_127", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"A\"}],\"x\":[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]}" + }, + { + "name": "depth_128", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"A\"}],\"x\":[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]}" + }, + { + "name": "empty_desc", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"A\"}],\"desc\":\"\"}" + } + ] + }, + "expected": [ + { + "name": "lone_surrogate_unknown_key", + "error": "json" + }, + { + "name": "lone_trailing_surrogate_name", + "error": "json" + }, + { + "name": "lone_surrogate_desc", + "error": "json" + }, + { + "name": "surrogate_pair_ok", + "json": "{\"v\":1,\"desc\":\"🚀\",\"columns\":[{\"id\":1,\"name\":\"A\"}]}" + }, + { + "name": "number_out_of_range", + "error": "json" + }, + { + "name": "arch_out_of_range", + "error": "json" + }, + { + "name": "depth_127", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"A\"}]}" + }, + { + "name": "depth_128", + "error": "json" + }, + { + "name": "empty_desc", + "json": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"A\"}]}" + } + ] +} diff --git a/forge-contracts/vectors/board_spec__values_dropped.json b/forge-contracts/vectors/board_spec__values_dropped.json new file mode 100644 index 000000000..847ee0ba9 --- /dev/null +++ b/forge-contracts/vectors/board_spec__values_dropped.json @@ -0,0 +1,125 @@ +{ + "name": "values_dropped", + "description": "A card's field values keep only fields the spec has, with a value of the field's type: an unknown field or option, a wrong type, a non-canonical key (\"01\"), a number past ±1e15 or below 1e-6, a bad date, a negative or fractional iteration, empty or 201-character text are dropped; -0 reads as 0; ids ascending.", + "case": "board_spec", + "rules": "v2", + "input": { + "op": "values", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + }, + { + "id": 6, + "name": "Summary", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "f": "{\"1\":7,\"2\":-0,\"3\":1.5,\"4\":\"2026-02-30\",\"5\":\"\",\"6\":\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\"9\":1,\"01\":2}" + }, + "expected": { + "values": { + "2": 0 + }, + "json": "{\"2\":0}" + } +} diff --git a/forge-contracts/vectors/board_spec__values_escapes.json b/forge-contracts/vectors/board_spec__values_escapes.json new file mode 100644 index 000000000..6ba60323d --- /dev/null +++ b/forge-contracts/vectors/board_spec__values_escapes.json @@ -0,0 +1,125 @@ +{ + "name": "values_escapes", + "description": "Text with quotes, backslashes, a newline and a control character round-trips with the same JSON escapes in both clients.", + "case": "board_spec", + "rules": "v2", + "input": { + "op": "values", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + }, + { + "id": 6, + "name": "Summary", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "f": "{\"5\":\"a\\\"b\\\\c\\nd\\u0001e
\"}" + }, + "expected": { + "values": { + "5": "a\"b\\c\nd\u0001e
" + }, + "json": "{\"5\":\"a\\\"b\\\\c\\nd\\u0001e
\"}" + } +} diff --git a/forge-contracts/vectors/board_spec__values_exact_numbers.json b/forge-contracts/vectors/board_spec__values_exact_numbers.json new file mode 100644 index 000000000..0de3ba7d5 --- /dev/null +++ b/forge-contracts/vectors/board_spec__values_exact_numbers.json @@ -0,0 +1,50 @@ +{ + "name": "values_exact_numbers", + "description": "Numbers read exactly (forge-core reads JSON with float_roundtrip, as JSON.parse does) and are written with JavaScript's shortest digits, an exact tie to even: 71292843364840.125 is written 71292843364840.12.", + "case": "board_spec", + "rules": "v2", + "input": { + "op": "values", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "C1" + } + ], + "fields": [ + { + "id": 1, + "name": "N1", + "type": "num" + }, + { + "id": 2, + "name": "N2", + "type": "num" + }, + { + "id": 3, + "name": "N3", + "type": "num" + }, + { + "id": 4, + "name": "N4", + "type": "num" + } + ] + }, + "f": "{\"1\":989238.7673074775,\"2\":123456789012345.67,\"3\":71292843364840.125,\"4\":1e-400}" + }, + "expected": { + "values": { + "1": 989238.7673074775, + "2": 123456789012345.67, + "3": 71292843364840.12, + "4": 0 + }, + "json": "{\"1\":989238.7673074775,\"2\":123456789012345.67,\"3\":71292843364840.12,\"4\":0}" + } +} diff --git a/forge-contracts/vectors/board_spec__values_kept.json b/forge-contracts/vectors/board_spec__values_kept.json new file mode 100644 index 000000000..f890745dc --- /dev/null +++ b/forge-contracts/vectors/board_spec__values_kept.json @@ -0,0 +1,130 @@ +{ + "name": "values_kept", + "description": "Valid values of every type survive (text up to 200 characters), and serialize canonically: ids ascending, numbers as JavaScript writes them.", + "case": "board_spec", + "rules": "v2", + "input": { + "op": "values", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + }, + { + "id": 6, + "name": "Summary", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "f": "{\"6\":\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\"5\":\"Ship it\",\"4\":\"2026-11-01\",\"3\":2,\"2\":2.5,\"1\":3}" + }, + "expected": { + "values": { + "1": 3, + "2": 2.5, + "3": 2, + "4": "2026-11-01", + "5": "Ship it", + "6": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + }, + "json": "{\"1\":3,\"2\":2.5,\"3\":2,\"4\":\"2026-11-01\",\"5\":\"Ship it\",\"6\":\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"}" + } +} diff --git a/forge-contracts/vectors/board_spec__values_lone_surrogate.json b/forge-contracts/vectors/board_spec__values_lone_surrogate.json new file mode 100644 index 000000000..e72a0e3cf --- /dev/null +++ b/forge-contracts/vectors/board_spec__values_lone_surrogate.json @@ -0,0 +1,123 @@ +{ + "name": "values_lone_surrogate", + "description": "An unpaired surrogate anywhere in f: no values.", + "case": "board_spec", + "rules": "v2", + "input": { + "op": "values", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + }, + { + "id": 6, + "name": "Summary", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "f": "{\"1\":1,\"5\":\"a\\udc00\"}" + }, + "expected": { + "values": {}, + "json": "{}" + } +} diff --git a/forge-contracts/vectors/board_spec__values_not_json.json b/forge-contracts/vectors/board_spec__values_not_json.json new file mode 100644 index 000000000..9dc699192 --- /dev/null +++ b/forge-contracts/vectors/board_spec__values_not_json.json @@ -0,0 +1,123 @@ +{ + "name": "values_not_json", + "description": "f that is not JSON reads as no values.", + "case": "board_spec", + "rules": "v2", + "input": { + "op": "values", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + }, + { + "id": 6, + "name": "Summary", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "f": "{\"1\":" + }, + "expected": { + "values": {}, + "json": "{}" + } +} diff --git a/forge-contracts/vectors/board_spec__values_not_object.json b/forge-contracts/vectors/board_spec__values_not_object.json new file mode 100644 index 000000000..b6ad171f4 --- /dev/null +++ b/forge-contracts/vectors/board_spec__values_not_object.json @@ -0,0 +1,123 @@ +{ + "name": "values_not_object", + "description": "f that is not JSON, or not an object, reads as no values.", + "case": "board_spec", + "rules": "v2", + "input": { + "op": "values", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + }, + { + "id": 6, + "name": "Summary", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "f": "[1,2]" + }, + "expected": { + "values": {}, + "json": "{}" + } +} diff --git a/forge-contracts/vectors/board_spec__values_null.json b/forge-contracts/vectors/board_spec__values_null.json new file mode 100644 index 000000000..2a1878ce1 --- /dev/null +++ b/forge-contracts/vectors/board_spec__values_null.json @@ -0,0 +1,123 @@ +{ + "name": "values_null", + "description": "A card without f has no values.", + "case": "board_spec", + "rules": "v2", + "input": { + "op": "values", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + }, + { + "id": 6, + "name": "Summary", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "f": null + }, + "expected": { + "values": {}, + "json": "{}" + } +} diff --git a/forge-contracts/vectors/board_spec__values_numbers.json b/forge-contracts/vectors/board_spec__values_numbers.json new file mode 100644 index 000000000..2c16dbaa4 --- /dev/null +++ b/forge-contracts/vectors/board_spec__values_numbers.json @@ -0,0 +1,60 @@ +{ + "name": "values_numbers", + "description": "Number fields: 1e15 and 1.5e-6 are kept (written without an exponent), 1e16 and 1e-7 dropped.", + "case": "board_spec", + "rules": "v2", + "input": { + "op": "values", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "C1" + } + ], + "fields": [ + { + "id": 1, + "name": "N1", + "type": "num" + }, + { + "id": 2, + "name": "N2", + "type": "num" + }, + { + "id": 3, + "name": "N3", + "type": "num" + }, + { + "id": 4, + "name": "N4", + "type": "num" + }, + { + "id": 5, + "name": "N5", + "type": "num" + }, + { + "id": 6, + "name": "N6", + "type": "num" + } + ] + }, + "f": "{\"1\":1e15,\"2\":1.5e-6,\"3\":1e16,\"4\":1e-7,\"5\":-123456.789,\"6\":0.1}" + }, + "expected": { + "values": { + "1": 1000000000000000, + "2": 0.0000015, + "5": -123456.789, + "6": 0.1 + }, + "json": "{\"1\":1000000000000000,\"2\":0.0000015,\"5\":-123456.789,\"6\":0.1}" + } +} diff --git a/forge-contracts/vectors/board_spec__values_overflow.json b/forge-contracts/vectors/board_spec__values_overflow.json new file mode 100644 index 000000000..fbfbd20ea --- /dev/null +++ b/forge-contracts/vectors/board_spec__values_overflow.json @@ -0,0 +1,62 @@ +{ + "name": "values_overflow", + "description": "Six 200-character text values of a two-byte letter are 2400+ bytes: they read, but writing them is refused (size, over 2048 bytes).", + "case": "board_spec", + "rules": "v2", + "input": { + "op": "values", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "C1" + } + ], + "fields": [ + { + "id": 1, + "name": "T1", + "type": "text" + }, + { + "id": 2, + "name": "T2", + "type": "text" + }, + { + "id": 3, + "name": "T3", + "type": "text" + }, + { + "id": 4, + "name": "T4", + "type": "text" + }, + { + "id": 5, + "name": "T5", + "type": "text" + }, + { + "id": 6, + "name": "T6", + "type": "text" + } + ] + }, + "f": "{\"1\":\"éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé\",\"2\":\"éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé\",\"3\":\"éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé\",\"4\":\"éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé\",\"5\":\"éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé\",\"6\":\"éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé\"}" + }, + "expected": { + "values": { + "1": "éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", + "2": "éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", + "3": "éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", + "4": "éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", + "5": "éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", + "6": "éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé" + }, + "error": "size" + } +} diff --git a/forge-contracts/vectors/board_spec__values_serde_refusals.json b/forge-contracts/vectors/board_spec__values_serde_refusals.json new file mode 100644 index 000000000..df0421e07 --- /dev/null +++ b/forge-contracts/vectors/board_spec__values_serde_refusals.json @@ -0,0 +1,123 @@ +{ + "name": "values_serde_refusals", + "description": "Field values forge-core's JSON reader would refuse (a number out of range, an unpaired surrogate) read as none in both clients.", + "case": "board_spec", + "rules": "v2", + "input": { + "op": "values", + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + }, + { + "id": 6, + "name": "Summary", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "f": "{\"1\":1,\"2\":1e400}" + }, + "expected": { + "values": {}, + "json": "{}" + } +} diff --git a/forge-contracts/vectors/board_view__group_assignee.json b/forge-contracts/vectors/board_view__group_assignee.json new file mode 100644 index 000000000..bf6951942 --- /dev/null +++ b/forge-contracts/vectors/board_view__group_assignee.json @@ -0,0 +1,298 @@ +{ + "name": "group_assignee", + "description": "Grouped by assignee: an item with two assignees is in both groups; no assignee first; ids by code point.", + "case": "board_view", + "rules": "v2", + "input": { + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "me": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb", + "items": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "number": 101, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791176400000, + "closedAt": null, + "title": "banana", + "labels": [ + "ui", + "bug" + ], + "assignees": [ + "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v2", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "number": 102, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791180000000, + "closedAt": null, + "title": "Apple", + "labels": [ + "bug" + ], + "assignees": [ + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v1", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "number": 103, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "bob/lib", + "kind": "issue", + "state": "open", + "createdAt": 1791183600000, + "closedAt": null, + "title": "cherry", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "number": 104, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791187200000, + "closedAt": 1793016000000, + "title": "date", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "number": 105, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "open", + "createdAt": 1791190800000, + "closedAt": null, + "title": "elder", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5", + "number": 106, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791194400000, + "closedAt": null, + "title": "fig", + "labels": [ + "ui" + ], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "col": 2, + "rank": "G", + "f": "{\"1\":2,\"2\":3,\"3\":1}", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "col": 2, + "rank": "F", + "f": "{\"1\":1,\"2\":5,\"3\":1}", + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "col": 1, + "rank": null, + "f": "{\"2\":2.5,\"3\":2}", + "state": 0 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244804000, + "item": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "col": 2, + "rank": null, + "f": "{\"1\":4,\"2\":1,\"3\":1}", + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244805000, + "item": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "col": 3, + "rank": null, + "f": "{\"2\":8,\"3\":0}", + "state": 0 + } + ], + "q": "", + "op": "group", + "by": "assignee" + }, + "expected": [ + { + "key": null, + "items": [ + "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5" + ] + }, + { + "key": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb", + "items": [ + "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3" + ] + }, + { + "key": "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "items": [ + "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn" + ] + } + ] +} diff --git a/forge-contracts/vectors/board_view__group_iteration.json b/forge-contracts/vectors/board_view__group_iteration.json new file mode 100644 index 000000000..b22b9fac8 --- /dev/null +++ b/forge-contracts/vectors/board_view__group_iteration.json @@ -0,0 +1,298 @@ +{ + "name": "group_iteration", + "description": "Grouped by an iteration field: no value first, then the iterations items name and the current one (index 1), ascending.", + "case": "board_view", + "rules": "v2", + "input": { + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "me": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb", + "items": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "number": 101, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791176400000, + "closedAt": null, + "title": "banana", + "labels": [ + "ui", + "bug" + ], + "assignees": [ + "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v2", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "number": 102, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791180000000, + "closedAt": null, + "title": "Apple", + "labels": [ + "bug" + ], + "assignees": [ + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v1", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "number": 103, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "bob/lib", + "kind": "issue", + "state": "open", + "createdAt": 1791183600000, + "closedAt": null, + "title": "cherry", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "number": 104, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791187200000, + "closedAt": 1793016000000, + "title": "date", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "number": 105, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "open", + "createdAt": 1791190800000, + "closedAt": null, + "title": "elder", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5", + "number": 106, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791194400000, + "closedAt": null, + "title": "fig", + "labels": [ + "ui" + ], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "col": 2, + "rank": "G", + "f": "{\"1\":2,\"2\":3,\"3\":1}", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "col": 2, + "rank": "F", + "f": "{\"1\":1,\"2\":5,\"3\":1}", + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "col": 1, + "rank": null, + "f": "{\"2\":2.5,\"3\":2}", + "state": 0 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244804000, + "item": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "col": 2, + "rank": null, + "f": "{\"1\":4,\"2\":1,\"3\":1}", + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244805000, + "item": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "col": 3, + "rank": null, + "f": "{\"2\":8,\"3\":0}", + "state": 0 + } + ], + "q": "-iteration:@current", + "op": "group", + "by": "f3" + }, + "expected": [ + { + "key": null, + "items": [ + "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5" + ] + }, + { + "key": 0, + "items": [ + "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp" + ] + }, + { + "key": 1, + "items": [] + }, + { + "key": 2, + "items": [ + "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ" + ] + } + ] +} diff --git a/forge-contracts/vectors/board_view__group_label.json b/forge-contracts/vectors/board_view__group_label.json new file mode 100644 index 000000000..720598c85 --- /dev/null +++ b/forge-contracts/vectors/board_view__group_label.json @@ -0,0 +1,298 @@ +{ + "name": "group_label", + "description": "Grouped by label: each of an item's labels, by code point.", + "case": "board_view", + "rules": "v2", + "input": { + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "me": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb", + "items": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "number": 101, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791176400000, + "closedAt": null, + "title": "banana", + "labels": [ + "ui", + "bug" + ], + "assignees": [ + "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v2", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "number": 102, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791180000000, + "closedAt": null, + "title": "Apple", + "labels": [ + "bug" + ], + "assignees": [ + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v1", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "number": 103, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "bob/lib", + "kind": "issue", + "state": "open", + "createdAt": 1791183600000, + "closedAt": null, + "title": "cherry", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "number": 104, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791187200000, + "closedAt": 1793016000000, + "title": "date", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "number": 105, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "open", + "createdAt": 1791190800000, + "closedAt": null, + "title": "elder", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5", + "number": 106, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791194400000, + "closedAt": null, + "title": "fig", + "labels": [ + "ui" + ], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "col": 2, + "rank": "G", + "f": "{\"1\":2,\"2\":3,\"3\":1}", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "col": 2, + "rank": "F", + "f": "{\"1\":1,\"2\":5,\"3\":1}", + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "col": 1, + "rank": null, + "f": "{\"2\":2.5,\"3\":2}", + "state": 0 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244804000, + "item": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "col": 2, + "rank": null, + "f": "{\"1\":4,\"2\":1,\"3\":1}", + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244805000, + "item": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "col": 3, + "rank": null, + "f": "{\"2\":8,\"3\":0}", + "state": 0 + } + ], + "q": "", + "op": "group", + "by": "label" + }, + "expected": [ + { + "key": null, + "items": [ + "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp" + ] + }, + { + "key": "bug", + "items": [ + "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3" + ] + }, + { + "key": "ui", + "items": [ + "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5" + ] + } + ] +} diff --git a/forge-contracts/vectors/board_view__group_milestone.json b/forge-contracts/vectors/board_view__group_milestone.json new file mode 100644 index 000000000..49e07737d --- /dev/null +++ b/forge-contracts/vectors/board_view__group_milestone.json @@ -0,0 +1,297 @@ +{ + "name": "group_milestone", + "description": "Grouped by milestone: none first, then titles by code point.", + "case": "board_view", + "rules": "v2", + "input": { + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "me": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb", + "items": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "number": 101, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791176400000, + "closedAt": null, + "title": "banana", + "labels": [ + "ui", + "bug" + ], + "assignees": [ + "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v2", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "number": 102, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791180000000, + "closedAt": null, + "title": "Apple", + "labels": [ + "bug" + ], + "assignees": [ + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v1", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "number": 103, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "bob/lib", + "kind": "issue", + "state": "open", + "createdAt": 1791183600000, + "closedAt": null, + "title": "cherry", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "number": 104, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791187200000, + "closedAt": 1793016000000, + "title": "date", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "number": 105, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "open", + "createdAt": 1791190800000, + "closedAt": null, + "title": "elder", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5", + "number": 106, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791194400000, + "closedAt": null, + "title": "fig", + "labels": [ + "ui" + ], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "col": 2, + "rank": "G", + "f": "{\"1\":2,\"2\":3,\"3\":1}", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "col": 2, + "rank": "F", + "f": "{\"1\":1,\"2\":5,\"3\":1}", + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "col": 1, + "rank": null, + "f": "{\"2\":2.5,\"3\":2}", + "state": 0 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244804000, + "item": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "col": 2, + "rank": null, + "f": "{\"1\":4,\"2\":1,\"3\":1}", + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244805000, + "item": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "col": 3, + "rank": null, + "f": "{\"2\":8,\"3\":0}", + "state": 0 + } + ], + "q": "", + "op": "group", + "by": "milestone" + }, + "expected": [ + { + "key": null, + "items": [ + "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5" + ] + }, + { + "key": "v1", + "items": [ + "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3" + ] + }, + { + "key": "v2", + "items": [ + "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn" + ] + } + ] +} diff --git a/forge-contracts/vectors/board_view__group_repo.json b/forge-contracts/vectors/board_view__group_repo.json new file mode 100644 index 000000000..5cc488cab --- /dev/null +++ b/forge-contracts/vectors/board_view__group_repo.json @@ -0,0 +1,292 @@ +{ + "name": "group_repo", + "description": "Grouped by repository (by id).", + "case": "board_view", + "rules": "v2", + "input": { + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "me": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb", + "items": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "number": 101, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791176400000, + "closedAt": null, + "title": "banana", + "labels": [ + "ui", + "bug" + ], + "assignees": [ + "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v2", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "number": 102, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791180000000, + "closedAt": null, + "title": "Apple", + "labels": [ + "bug" + ], + "assignees": [ + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v1", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "number": 103, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "bob/lib", + "kind": "issue", + "state": "open", + "createdAt": 1791183600000, + "closedAt": null, + "title": "cherry", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "number": 104, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791187200000, + "closedAt": 1793016000000, + "title": "date", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "number": 105, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "open", + "createdAt": 1791190800000, + "closedAt": null, + "title": "elder", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5", + "number": 106, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791194400000, + "closedAt": null, + "title": "fig", + "labels": [ + "ui" + ], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "col": 2, + "rank": "G", + "f": "{\"1\":2,\"2\":3,\"3\":1}", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "col": 2, + "rank": "F", + "f": "{\"1\":1,\"2\":5,\"3\":1}", + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "col": 1, + "rank": null, + "f": "{\"2\":2.5,\"3\":2}", + "state": 0 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244804000, + "item": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "col": 2, + "rank": null, + "f": "{\"1\":4,\"2\":1,\"3\":1}", + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244805000, + "item": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "col": 3, + "rank": null, + "f": "{\"2\":8,\"3\":0}", + "state": 0 + } + ], + "q": "", + "op": "group", + "by": "repo" + }, + "expected": [ + { + "key": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "items": [ + "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5" + ] + }, + { + "key": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "items": [ + "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ" + ] + } + ] +} diff --git a/forge-contracts/vectors/board_view__group_select.json b/forge-contracts/vectors/board_view__group_select.json new file mode 100644 index 000000000..607ebce9f --- /dev/null +++ b/forge-contracts/vectors/board_view__group_select.json @@ -0,0 +1,306 @@ +{ + "name": "group_select", + "description": "Grouped by a select field: \"No Priority\" (null) first while it holds an item, then every option in order.", + "case": "board_view", + "rules": "v2", + "input": { + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "me": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb", + "items": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "number": 101, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791176400000, + "closedAt": null, + "title": "banana", + "labels": [ + "ui", + "bug" + ], + "assignees": [ + "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v2", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "number": 102, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791180000000, + "closedAt": null, + "title": "Apple", + "labels": [ + "bug" + ], + "assignees": [ + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v1", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "number": 103, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "bob/lib", + "kind": "issue", + "state": "open", + "createdAt": 1791183600000, + "closedAt": null, + "title": "cherry", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "number": 104, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791187200000, + "closedAt": 1793016000000, + "title": "date", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "number": 105, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "open", + "createdAt": 1791190800000, + "closedAt": null, + "title": "elder", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5", + "number": 106, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791194400000, + "closedAt": null, + "title": "fig", + "labels": [ + "ui" + ], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "col": 2, + "rank": "G", + "f": "{\"1\":2,\"2\":3,\"3\":1}", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "col": 2, + "rank": "F", + "f": "{\"1\":1,\"2\":5,\"3\":1}", + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "col": 1, + "rank": null, + "f": "{\"2\":2.5,\"3\":2}", + "state": 0 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244804000, + "item": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "col": 2, + "rank": null, + "f": "{\"1\":4,\"2\":1,\"3\":1}", + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244805000, + "item": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "col": 3, + "rank": null, + "f": "{\"2\":8,\"3\":0}", + "state": 0 + } + ], + "q": "", + "op": "group", + "by": "f1" + }, + "expected": [ + { + "key": null, + "items": [ + "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5" + ] + }, + { + "key": 1, + "items": [ + "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3" + ] + }, + { + "key": 2, + "items": [ + "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn" + ] + }, + { + "key": 3, + "items": [] + }, + { + "key": 4, + "items": [ + "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ" + ] + } + ] +} diff --git a/forge-contracts/vectors/board_view__group_status.json b/forge-contracts/vectors/board_view__group_status.json new file mode 100644 index 000000000..e6eef67b0 --- /dev/null +++ b/forge-contracts/vectors/board_view__group_status.json @@ -0,0 +1,301 @@ +{ + "name": "group_status", + "description": "Grouped by status: every column in order (empty ones too), items in input order; No status only while it holds an item (default Todo here, so none).", + "case": "board_view", + "rules": "v2", + "input": { + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "me": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb", + "items": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "number": 101, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791176400000, + "closedAt": null, + "title": "banana", + "labels": [ + "ui", + "bug" + ], + "assignees": [ + "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v2", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "number": 102, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791180000000, + "closedAt": null, + "title": "Apple", + "labels": [ + "bug" + ], + "assignees": [ + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v1", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "number": 103, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "bob/lib", + "kind": "issue", + "state": "open", + "createdAt": 1791183600000, + "closedAt": null, + "title": "cherry", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "number": 104, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791187200000, + "closedAt": 1793016000000, + "title": "date", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "number": 105, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "open", + "createdAt": 1791190800000, + "closedAt": null, + "title": "elder", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5", + "number": 106, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791194400000, + "closedAt": null, + "title": "fig", + "labels": [ + "ui" + ], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "col": 2, + "rank": "G", + "f": "{\"1\":2,\"2\":3,\"3\":1}", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "col": 2, + "rank": "F", + "f": "{\"1\":1,\"2\":5,\"3\":1}", + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "col": 1, + "rank": null, + "f": "{\"2\":2.5,\"3\":2}", + "state": 0 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244804000, + "item": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "col": 2, + "rank": null, + "f": "{\"1\":4,\"2\":1,\"3\":1}", + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244805000, + "item": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "col": 3, + "rank": null, + "f": "{\"2\":8,\"3\":0}", + "state": 0 + } + ], + "q": "", + "op": "group", + "by": "status" + }, + "expected": [ + { + "key": 1, + "items": [ + "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5" + ] + }, + { + "key": 2, + "items": [ + "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3" + ] + }, + { + "key": 3, + "items": [ + "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp" + ] + }, + { + "key": 4, + "items": [] + } + ] +} diff --git a/forge-contracts/vectors/board_view__group_unknown.json b/forge-contracts/vectors/board_view__group_unknown.json new file mode 100644 index 000000000..876ea8843 --- /dev/null +++ b/forge-contracts/vectors/board_view__group_unknown.json @@ -0,0 +1,287 @@ +{ + "name": "group_unknown", + "description": "A key that does not group (a number field) is one group of everything.", + "case": "board_view", + "rules": "v2", + "input": { + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "me": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb", + "items": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "number": 101, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791176400000, + "closedAt": null, + "title": "banana", + "labels": [ + "ui", + "bug" + ], + "assignees": [ + "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v2", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "number": 102, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791180000000, + "closedAt": null, + "title": "Apple", + "labels": [ + "bug" + ], + "assignees": [ + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v1", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "number": 103, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "bob/lib", + "kind": "issue", + "state": "open", + "createdAt": 1791183600000, + "closedAt": null, + "title": "cherry", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "number": 104, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791187200000, + "closedAt": 1793016000000, + "title": "date", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "number": 105, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "open", + "createdAt": 1791190800000, + "closedAt": null, + "title": "elder", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5", + "number": 106, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791194400000, + "closedAt": null, + "title": "fig", + "labels": [ + "ui" + ], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "col": 2, + "rank": "G", + "f": "{\"1\":2,\"2\":3,\"3\":1}", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "col": 2, + "rank": "F", + "f": "{\"1\":1,\"2\":5,\"3\":1}", + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "col": 1, + "rank": null, + "f": "{\"2\":2.5,\"3\":2}", + "state": 0 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244804000, + "item": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "col": 2, + "rank": null, + "f": "{\"1\":4,\"2\":1,\"3\":1}", + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244805000, + "item": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "col": 3, + "rank": null, + "f": "{\"2\":8,\"3\":0}", + "state": 0 + } + ], + "q": "", + "op": "group", + "by": "f2" + }, + "expected": [ + { + "key": null, + "items": [ + "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5" + ] + } + ] +} diff --git a/forge-contracts/vectors/board_view__progress.json b/forge-contracts/vectors/board_view__progress.json new file mode 100644 index 000000000..c081cd8b6 --- /dev/null +++ b/forge-contracts/vectors/board_view__progress.json @@ -0,0 +1,282 @@ +{ + "name": "progress", + "description": "Iteration progress (index 1): done is in the Done column or closed/merged; points from Estimate.", + "case": "board_view", + "rules": "v2", + "input": { + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "me": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb", + "items": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "number": 101, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791176400000, + "closedAt": null, + "title": "banana", + "labels": [ + "ui", + "bug" + ], + "assignees": [ + "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v2", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "number": 102, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791180000000, + "closedAt": null, + "title": "Apple", + "labels": [ + "bug" + ], + "assignees": [ + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v1", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "number": 103, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "bob/lib", + "kind": "issue", + "state": "open", + "createdAt": 1791183600000, + "closedAt": null, + "title": "cherry", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "number": 104, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791187200000, + "closedAt": 1793016000000, + "title": "date", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "number": 105, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "open", + "createdAt": 1791190800000, + "closedAt": null, + "title": "elder", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5", + "number": 106, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791194400000, + "closedAt": null, + "title": "fig", + "labels": [ + "ui" + ], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "col": 2, + "rank": "G", + "f": "{\"1\":2,\"2\":3,\"3\":1}", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "col": 2, + "rank": "F", + "f": "{\"1\":1,\"2\":5,\"3\":1}", + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "col": 1, + "rank": null, + "f": "{\"2\":2.5,\"3\":2}", + "state": 0 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244804000, + "item": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "col": 2, + "rank": null, + "f": "{\"1\":4,\"2\":1,\"3\":1}", + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244805000, + "item": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "col": 3, + "rank": null, + "f": "{\"2\":8,\"3\":0}", + "state": 0 + } + ], + "q": "", + "op": "progress", + "field": 3, + "k": 1, + "points": 2 + }, + "expected": { + "total": 3, + "done": 1, + "points": 9, + "donePoints": 1 + } +} diff --git a/forge-contracts/vectors/board_view__progress_no_points.json b/forge-contracts/vectors/board_view__progress_no_points.json new file mode 100644 index 000000000..ad01e5c29 --- /dev/null +++ b/forge-contracts/vectors/board_view__progress_no_points.json @@ -0,0 +1,282 @@ +{ + "name": "progress_no_points", + "description": "Iteration progress without a points field: counts only.", + "case": "board_view", + "rules": "v2", + "input": { + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "me": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb", + "items": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "number": 101, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791176400000, + "closedAt": null, + "title": "banana", + "labels": [ + "ui", + "bug" + ], + "assignees": [ + "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v2", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "number": 102, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791180000000, + "closedAt": null, + "title": "Apple", + "labels": [ + "bug" + ], + "assignees": [ + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v1", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "number": 103, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "bob/lib", + "kind": "issue", + "state": "open", + "createdAt": 1791183600000, + "closedAt": null, + "title": "cherry", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "number": 104, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791187200000, + "closedAt": 1793016000000, + "title": "date", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "number": 105, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "open", + "createdAt": 1791190800000, + "closedAt": null, + "title": "elder", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5", + "number": 106, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791194400000, + "closedAt": null, + "title": "fig", + "labels": [ + "ui" + ], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "col": 2, + "rank": "G", + "f": "{\"1\":2,\"2\":3,\"3\":1}", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "col": 2, + "rank": "F", + "f": "{\"1\":1,\"2\":5,\"3\":1}", + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "col": 1, + "rank": null, + "f": "{\"2\":2.5,\"3\":2}", + "state": 0 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244804000, + "item": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "col": 2, + "rank": null, + "f": "{\"1\":4,\"2\":1,\"3\":1}", + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244805000, + "item": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "col": 3, + "rank": null, + "f": "{\"2\":8,\"3\":0}", + "state": 0 + } + ], + "q": "", + "op": "progress", + "field": 3, + "k": 0, + "points": null + }, + "expected": { + "total": 1, + "done": 1, + "points": null, + "donePoints": null + } +} diff --git a/forge-contracts/vectors/board_view__sort.json b/forge-contracts/vectors/board_view__sort.json new file mode 100644 index 000000000..0a2f40476 --- /dev/null +++ b/forge-contracts/vectors/board_view__sort.json @@ -0,0 +1,394 @@ +{ + "name": "sort", + "description": "Sorts: rank (the default, and -rank), title (any case), -estimate (missing last), priority by option order, status by column order, number, created, -created; ties by (rank, id).", + "case": "board_view", + "rules": "v2", + "input": { + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "me": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb", + "items": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "number": 101, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791176400000, + "closedAt": null, + "title": "banana", + "labels": [ + "ui", + "bug" + ], + "assignees": [ + "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v2", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "number": 102, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791180000000, + "closedAt": null, + "title": "Apple", + "labels": [ + "bug" + ], + "assignees": [ + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v1", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "number": 103, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "bob/lib", + "kind": "issue", + "state": "open", + "createdAt": 1791183600000, + "closedAt": null, + "title": "cherry", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "number": 104, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791187200000, + "closedAt": 1793016000000, + "title": "date", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "number": 105, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "open", + "createdAt": 1791190800000, + "closedAt": null, + "title": "elder", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5", + "number": 106, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791194400000, + "closedAt": null, + "title": "fig", + "labels": [ + "ui" + ], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "col": 2, + "rank": "G", + "f": "{\"1\":2,\"2\":3,\"3\":1}", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "col": 2, + "rank": "F", + "f": "{\"1\":1,\"2\":5,\"3\":1}", + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "col": 1, + "rank": null, + "f": "{\"2\":2.5,\"3\":2}", + "state": 0 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244804000, + "item": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "col": 2, + "rank": null, + "f": "{\"1\":4,\"2\":1,\"3\":1}", + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244805000, + "item": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "col": 3, + "rank": null, + "f": "{\"2\":8,\"3\":0}", + "state": 0 + } + ], + "q": "", + "op": "sort", + "sorts": [ + null, + "rank", + "-rank", + "title", + "-f2", + "f2", + "f1", + "-f1", + "status", + "number", + "-created", + "repo", + "milestone" + ] + }, + "expected": [ + [ + "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5" + ], + [ + "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5" + ], + [ + "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5", + "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3" + ], + [ + "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5" + ], + [ + "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5" + ], + [ + "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5" + ], + [ + "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5" + ], + [ + "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5" + ], + [ + "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5", + "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp" + ], + [ + "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5" + ], + [ + "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5", + "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn" + ], + [ + "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5", + "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ" + ], + [ + "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5" + ] + ] +} diff --git a/forge-contracts/vectors/board_view__sort_repo.json b/forge-contracts/vectors/board_view__sort_repo.json new file mode 100644 index 000000000..4da40b3b5 --- /dev/null +++ b/forge-contracts/vectors/board_view__sort_repo.json @@ -0,0 +1,295 @@ +{ + "name": "sort_repo", + "description": "Sorting by repository orders by repository id, not by the label a client gives it (here the labels sort the other way): -repo reverses it; ties by (rank, id).", + "case": "board_view", + "rules": "v2", + "input": { + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "me": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb", + "items": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "number": 101, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "zed/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791176400000, + "closedAt": null, + "title": "banana", + "labels": [ + "ui", + "bug" + ], + "assignees": [ + "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v2", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "number": 102, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "zed/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791180000000, + "closedAt": null, + "title": "Apple", + "labels": [ + "bug" + ], + "assignees": [ + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v1", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "number": 103, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "alice/lib", + "kind": "issue", + "state": "open", + "createdAt": 1791183600000, + "closedAt": null, + "title": "cherry", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "number": 104, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "zed/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791187200000, + "closedAt": 1793016000000, + "title": "date", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "number": 105, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "zed/forge", + "kind": "pr", + "state": "open", + "createdAt": 1791190800000, + "closedAt": null, + "title": "elder", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5", + "number": 106, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "zed/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791194400000, + "closedAt": null, + "title": "fig", + "labels": [ + "ui" + ], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "col": 2, + "rank": "G", + "f": "{\"1\":2,\"2\":3,\"3\":1}", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "col": 2, + "rank": "F", + "f": "{\"1\":1,\"2\":5,\"3\":1}", + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "col": 1, + "rank": null, + "f": "{\"2\":2.5,\"3\":2}", + "state": 0 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244804000, + "item": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "col": 2, + "rank": null, + "f": "{\"1\":4,\"2\":1,\"3\":1}", + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244805000, + "item": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "col": 3, + "rank": null, + "f": "{\"2\":8,\"3\":0}", + "state": 0 + } + ], + "q": "", + "op": "sort", + "sorts": [ + "repo", + "-repo" + ] + }, + "expected": [ + [ + "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5", + "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ" + ], + [ + "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5" + ] + ] +} diff --git a/forge-contracts/vectors/board_view__totals.json b/forge-contracts/vectors/board_view__totals.json new file mode 100644 index 000000000..b8dcc5387 --- /dev/null +++ b/forge-contracts/vectors/board_view__totals.json @@ -0,0 +1,304 @@ +{ + "name": "totals", + "description": "Column totals: count and the sum of the view's first number field (Table: Estimate), the WIP limit and over it (In progress: 3 items, limit 1).", + "case": "board_view", + "rules": "v2", + "input": { + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "me": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb", + "items": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "number": 101, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791176400000, + "closedAt": null, + "title": "banana", + "labels": [ + "ui", + "bug" + ], + "assignees": [ + "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v2", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "number": 102, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791180000000, + "closedAt": null, + "title": "Apple", + "labels": [ + "bug" + ], + "assignees": [ + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v1", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "number": 103, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "bob/lib", + "kind": "issue", + "state": "open", + "createdAt": 1791183600000, + "closedAt": null, + "title": "cherry", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "number": 104, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791187200000, + "closedAt": 1793016000000, + "title": "date", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "number": 105, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "open", + "createdAt": 1791190800000, + "closedAt": null, + "title": "elder", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5", + "number": 106, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791194400000, + "closedAt": null, + "title": "fig", + "labels": [ + "ui" + ], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "col": 2, + "rank": "G", + "f": "{\"1\":2,\"2\":3,\"3\":1}", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "col": 2, + "rank": "F", + "f": "{\"1\":1,\"2\":5,\"3\":1}", + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "col": 1, + "rank": null, + "f": "{\"2\":2.5,\"3\":2}", + "state": 0 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244804000, + "item": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "col": 2, + "rank": null, + "f": "{\"1\":4,\"2\":1,\"3\":1}", + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244805000, + "item": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "col": 3, + "rank": null, + "f": "{\"2\":8,\"3\":0}", + "state": 0 + } + ], + "q": "", + "op": "totals", + "view": 2 + }, + "expected": [ + { + "id": 1, + "count": 2, + "sum": 2.5, + "wip": null, + "over": false + }, + { + "id": 2, + "count": 2, + "sum": 8, + "wip": 1, + "over": true + }, + { + "id": 3, + "count": 2, + "sum": 9, + "wip": null, + "over": false + }, + { + "id": 4, + "count": 0, + "sum": 0, + "wip": null, + "over": false + } + ] +} diff --git a/forge-contracts/vectors/board_view__totals_default_view.json b/forge-contracts/vectors/board_view__totals_default_view.json new file mode 100644 index 000000000..164dab39b --- /dev/null +++ b/forge-contracts/vectors/board_view__totals_default_view.json @@ -0,0 +1,304 @@ +{ + "name": "totals_default_view", + "description": "With no view the spec's first number field is summed.", + "case": "board_view", + "rules": "v2", + "input": { + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "me": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb", + "items": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "number": 101, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791176400000, + "closedAt": null, + "title": "banana", + "labels": [ + "ui", + "bug" + ], + "assignees": [ + "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v2", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "number": 102, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791180000000, + "closedAt": null, + "title": "Apple", + "labels": [ + "bug" + ], + "assignees": [ + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v1", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "number": 103, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "bob/lib", + "kind": "issue", + "state": "open", + "createdAt": 1791183600000, + "closedAt": null, + "title": "cherry", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "number": 104, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791187200000, + "closedAt": 1793016000000, + "title": "date", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "number": 105, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "open", + "createdAt": 1791190800000, + "closedAt": null, + "title": "elder", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5", + "number": 106, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791194400000, + "closedAt": null, + "title": "fig", + "labels": [ + "ui" + ], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "col": 2, + "rank": "G", + "f": "{\"1\":2,\"2\":3,\"3\":1}", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "col": 2, + "rank": "F", + "f": "{\"1\":1,\"2\":5,\"3\":1}", + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "col": 1, + "rank": null, + "f": "{\"2\":2.5,\"3\":2}", + "state": 0 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244804000, + "item": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "col": 2, + "rank": null, + "f": "{\"1\":4,\"2\":1,\"3\":1}", + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244805000, + "item": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "col": 3, + "rank": null, + "f": "{\"2\":8,\"3\":0}", + "state": 0 + } + ], + "q": "label:bug", + "op": "totals", + "view": null + }, + "expected": [ + { + "id": 1, + "count": 0, + "sum": 0, + "wip": null, + "over": false + }, + { + "id": 2, + "count": 2, + "sum": 8, + "wip": 1, + "over": true + }, + { + "id": 3, + "count": 0, + "sum": 0, + "wip": null, + "over": false + }, + { + "id": 4, + "count": 0, + "sum": 0, + "wip": null, + "over": false + } + ] +} diff --git a/forge-contracts/vectors/board_view__totals_no_number_field.json b/forge-contracts/vectors/board_view__totals_no_number_field.json new file mode 100644 index 000000000..d6a719eb8 --- /dev/null +++ b/forge-contracts/vectors/board_view__totals_no_number_field.json @@ -0,0 +1,304 @@ +{ + "name": "totals_no_number_field", + "description": "A view whose fields have no number field sums nothing (null); no view sums the spec's first number field.", + "case": "board_view", + "rules": "v2", + "input": { + "spec": { + "v": 1, + "columns": [ + { + "id": 1, + "name": "Todo" + }, + { + "id": 2, + "name": "In progress", + "wip": 1 + }, + { + "id": 3, + "name": "Done" + }, + { + "id": 4, + "name": "Verified" + } + ], + "def": 1, + "done": 3, + "sources": [ + { + "k": "a" + } + ], + "fields": [ + { + "id": 1, + "name": "Priority", + "type": "sel", + "options": [ + { + "id": 1, + "name": "P0" + }, + { + "id": 2, + "name": "P1" + }, + { + "id": 3, + "name": "P2" + }, + { + "id": 4, + "name": "P3" + } + ] + }, + { + "id": 2, + "name": "Estimate", + "type": "num" + }, + { + "id": 3, + "name": "Iteration", + "type": "iter", + "start": "2026-10-12", + "days": 14 + }, + { + "id": 4, + "name": "Target", + "type": "date" + }, + { + "id": 5, + "name": "Notes", + "type": "text" + } + ], + "views": [ + { + "id": 1, + "name": "Board", + "layout": "board" + }, + { + "id": 2, + "name": "Table", + "layout": "table", + "cols": [ + "title", + "status", + "f1", + "f2" + ] + }, + { + "id": 3, + "name": "Plain", + "layout": "table", + "cols": [ + "title", + "f5" + ] + } + ], + "arch": 14 + }, + "home": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "now": 1793102400000, + "me": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb", + "items": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "number": 101, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791176400000, + "closedAt": null, + "title": "banana", + "labels": [ + "ui", + "bug" + ], + "assignees": [ + "Fss2iV8Cv3jH4UPUtYcszb2Bc3bsTqXPjZM8D7tKmg9r", + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v2", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "number": 102, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791180000000, + "closedAt": null, + "title": "Apple", + "labels": [ + "bug" + ], + "assignees": [ + "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + ], + "milestone": "v1", + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "number": 103, + "repoId": "EZZTFGPPNXqHudAJPvw2YiYjtJgqZwbxXiSkBHjE43Nx", + "repo": "bob/lib", + "kind": "issue", + "state": "open", + "createdAt": 1791183600000, + "closedAt": null, + "title": "cherry", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "number": 104, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "closed", + "createdAt": 1791187200000, + "closedAt": 1793016000000, + "title": "date", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "number": 105, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "pr", + "state": "open", + "createdAt": 1791190800000, + "closedAt": null, + "title": "elder", + "labels": [], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + }, + { + "id": "8CHyD97xDGLH2PDYW7cDaR8sjsaR8mCNBVfbjoN4Ner5", + "number": 106, + "repoId": "EVYovg1cuLSRZwsgUgCkwLTaVSyBUhisxmaEqH7xnN3h", + "repo": "alice/forge", + "kind": "issue", + "state": "open", + "createdAt": 1791194400000, + "closedAt": null, + "title": "fig", + "labels": [ + "ui" + ], + "assignees": [], + "milestone": null, + "author": "ForPPtkSSrLQio6ryHtcPCw2DBtDNbeKAcUcs7H4Vzpb" + } + ], + "cards": [ + { + "id": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244801000, + "item": "7rEkcBF7sHMwKznSuqxsXWh4maz8gZnyLmK51kKk2GBn", + "col": 2, + "rank": "G", + "f": "{\"1\":2,\"2\":3,\"3\":1}", + "state": 0 + }, + { + "id": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244802000, + "item": "7vFPvmctLUkofg54q6h98tnEAShnmog3uiBaMkw1HwX3", + "col": 2, + "rank": "F", + "f": "{\"1\":1,\"2\":5,\"3\":1}", + "state": 0 + }, + { + "id": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244803000, + "item": "7zG3FMzeog9g1MMgkMRQkGsPZJRSs3Z8Uf45hmYGZcrJ", + "col": 1, + "rank": null, + "f": "{\"2\":2.5,\"3\":2}", + "state": 0 + }, + { + "id": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244804000, + "item": "84GgZxNRGsYYM2eJfc9gMexYxA96xHSD3bvb3n9XqJBZ", + "col": 2, + "rank": null, + "f": "{\"1\":4,\"2\":1,\"3\":1}", + "state": 0 + }, + { + "id": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "ownerId": "FBfF8bmHbJP6xijsfDVT39MCS29kP6XfeEHJHPCbV9NH", + "updatedAt": 1791244805000, + "item": "88HKtYkBk4wQghvvarswy33iM1rm3XKHcYo6Pnko6yWp", + "col": 3, + "rank": null, + "f": "{\"2\":8,\"3\":0}", + "state": 0 + } + ], + "q": "is:open", + "op": "totals", + "view": 3 + }, + "expected": [ + { + "id": 1, + "count": 2, + "sum": null, + "wip": null, + "over": false + }, + { + "id": 2, + "count": 2, + "sum": null, + "wip": 1, + "over": true + }, + { + "id": 3, + "count": 1, + "sum": null, + "wip": null, + "over": false + }, + { + "id": 4, + "count": 0, + "sum": null, + "wip": null, + "over": false + } + ] +} diff --git a/forge-contracts/vectors/rc1/forge-community.indices.json b/forge-contracts/vectors/rc1/forge-community.indices.json index 418464e54..baffa089f 100644 --- a/forge-contracts/vectors/rc1/forge-community.indices.json +++ b/forge-contracts/vectors/rc1/forge-community.indices.json @@ -43,6 +43,18 @@ "type": "vaultEntry", "expect": "absent" }, + { + "item": "U3", + "name": "no board type", + "type": "board", + "expect": "absent" + }, + { + "item": "U3", + "name": "no card type", + "type": "card", + "expect": "absent" + }, { "item": "EVK", "name": "no byKind index", diff --git a/forge-contracts/vectors/sealed_board__open_board.json b/forge-contracts/vectors/sealed_board__open_board.json new file mode 100644 index 000000000..8b0928c1d --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_board.json @@ -0,0 +1,37 @@ +{ + "name": "open_board", + "description": "a sealed board opens under K_0 to its name and definition.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + } + }, + "members": [] + }, + "doc": { + "type": "board", + "key": 7, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 0, + "plaintext": false, + "enc": "01000102030405060708090a0b3e7028a0ac5388143e0c35b3b050df789b274eea479160eb2cfbec2fbba79e8a330954a9e8700f356020378f2350e347a9d8bd0f55aac03fe2ae2265e98dfa589874658be2f70d3a8102d8736fdb4c99f93726ec567354e3eb4cf7685f5b3950e9c00e6a81460d91e36cde8ada3ad90c548e031d6e78adaa21612b6862e4008ef93596fbe90429874f25150568ec0e65" + } + }, + "expected": { + "status": "readable", + "fields": { + "name": "Roadmap", + "spec": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"In progress\"},{\"id\":3,\"name\":\"Done\"}],\"def\":1,\"done\":3}" + } + } +} diff --git a/forge-contracts/vectors/sealed_board__open_board_epoch1.json b/forge-contracts/vectors/sealed_board__open_board_epoch1.json new file mode 100644 index 000000000..6f6a12087 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_board_epoch1.json @@ -0,0 +1,42 @@ +{ + "name": "open_board_epoch1", + "description": "a board sealed under epoch 1 opens with K_1.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", + "1": "202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + }, + "1": { + "id": "723e4415b140d11aae49ab4d7cbf0e3f418bb90092a5ab040d47602af4ba5a86", + "height": 1000 + } + }, + "members": [] + }, + "doc": { + "type": "board", + "key": 7, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 1, + "plaintext": false, + "enc": "01000102030405060708090a0bf6b9c40c7ba5b252a436a4cb9e96caa8704c39c480f0b41453c060256b136e03f7b379e6e39a1009d28adb1b426b75caef9efb7b0a350effcc3b561ea101230a9bd159c631199f28bdccde8822b545fc1cb5cdf13893f701c0a0271eb85ab07cf9c1c7ee3cd57420ec2330ba92c188a7d2d77afd8712107516ce80db327fa3bade35dd1731e53a6240182aaa50563d11" + } + }, + "expected": { + "status": "readable", + "fields": { + "name": "Roadmap", + "spec": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"In progress\"},{\"id\":3,\"name\":\"Done\"}],\"def\":1,\"done\":3}" + } + } +} diff --git a/forge-contracts/vectors/sealed_board__open_board_moved_to_other_key.json b/forge-contracts/vectors/sealed_board__open_board_moved_to_other_key.json new file mode 100644 index 000000000..aa8d5a4eb --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_board_moved_to_other_key.json @@ -0,0 +1,34 @@ +{ + "name": "open_board_moved_to_other_key", + "description": "a board's enc copied under another key fails the tag.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + } + }, + "members": [] + }, + "doc": { + "type": "board", + "key": 8, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 0, + "plaintext": false, + "enc": "01000102030405060708090a0b3e7028a0ac5388143e0c35b3b050df789b274eea479160eb2cfbec2fbba79e8a330954a9e8700f356020378f2350e347a9d8bd0f55aac03fe2ae2265e98dfa589874658be2f70d3a8102d8736fdb4c99f93726ec567354e3eb4cf7685f5b3950e9c00e6a81460d91e36cde8ada3ad90c548e031d6e78adaa21612b6862e4008ef93596fbe90429874f25150568ec0e65" + } + }, + "expected": { + "status": "unreadable", + "reason": "badTag" + } +} diff --git a/forge-contracts/vectors/sealed_board__open_card.json b/forge-contracts/vectors/sealed_board__open_card.json new file mode 100644 index 000000000..79d893d0e --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_card.json @@ -0,0 +1,39 @@ +{ + "name": "open_card", + "description": "a sealed card opens to its column, rank and field values.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + } + }, + "members": [] + }, + "doc": { + "type": "card", + "board": 7, + "item": "4444444444444444444444444444444444444444444444444444444444444444", + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 0, + "plaintext": false, + "enc": "01000102030405060708090a0b3c702ef0e032ed2f7b7c13c8e21adf348a603fc66ef20f875996825c999dc5f110d66cf89f88d3cc7f0518ed1c5e3f18" + } + }, + "expected": { + "status": "readable", + "fields": { + "col": 2, + "rank": "V", + "f": "{\"1\":3}" + } + } +} diff --git a/forge-contracts/vectors/sealed_board__open_card_empty.json b/forge-contracts/vectors/sealed_board__open_card_empty.json new file mode 100644 index 000000000..44ead2f3c --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_card_empty.json @@ -0,0 +1,35 @@ +{ + "name": "open_card_empty", + "description": "a card sealed with no fields opens to none.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + } + }, + "members": [] + }, + "doc": { + "type": "card", + "board": 7, + "item": "4444444444444444444444444444444444444444444444444444444444444444", + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 0, + "plaintext": false, + "enc": "01000102030405060708090a0b5e7032f2c332ec795f7c14b3c02bfd0eb91d7fc665f20f875996825c999dc5f1eb65592e9a7b12b6a67c5d40a1fb72bd" + } + }, + "expected": { + "status": "readable", + "fields": {} + } +} diff --git a/forge-contracts/vectors/sealed_board__open_card_enc_as_board.json b/forge-contracts/vectors/sealed_board__open_card_enc_as_board.json new file mode 100644 index 000000000..7a2c980f7 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_card_enc_as_board.json @@ -0,0 +1,34 @@ +{ + "name": "open_card_enc_as_board", + "description": "the AD binds the type: a card's enc stored as a board (key 7, the card's board) fails the tag.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + } + }, + "members": [] + }, + "doc": { + "type": "board", + "key": 7, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 0, + "plaintext": false, + "enc": "01000102030405060708090a0b3c702ef0e032ed2f7b7c13c8e21adf348a603fc66ef20f875996825c999dc5f110d66cf89f88d3cc7f0518ed1c5e3f18" + } + }, + "expected": { + "status": "unreadable", + "reason": "badTag" + } +} diff --git a/forge-contracts/vectors/sealed_board__open_card_moved_to_other_board.json b/forge-contracts/vectors/sealed_board__open_card_moved_to_other_board.json new file mode 100644 index 000000000..f9e0dbbd5 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_card_moved_to_other_board.json @@ -0,0 +1,35 @@ +{ + "name": "open_card_moved_to_other_board", + "description": "the AD binds the board key: the enc copied to another board fails the tag.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + } + }, + "members": [] + }, + "doc": { + "type": "card", + "board": 8, + "item": "4444444444444444444444444444444444444444444444444444444444444444", + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 0, + "plaintext": false, + "enc": "01000102030405060708090a0b3c702ef0e032ed2f7b7c13c8e21adf348a603fc66ef20f875996825c999dc5f110d66cf89f88d3cc7f0518ed1c5e3f18" + } + }, + "expected": { + "status": "unreadable", + "reason": "badTag" + } +} diff --git a/forge-contracts/vectors/sealed_board__open_card_moved_to_other_item.json b/forge-contracts/vectors/sealed_board__open_card_moved_to_other_item.json new file mode 100644 index 000000000..4cd49fa8b --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_card_moved_to_other_item.json @@ -0,0 +1,35 @@ +{ + "name": "open_card_moved_to_other_item", + "description": "the AD binds the item: a card's enc copied onto a card for another item fails the tag.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + } + }, + "members": [] + }, + "doc": { + "type": "card", + "board": 7, + "item": "4545454545454545454545454545454545454545454545454545454545454545", + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 0, + "plaintext": false, + "enc": "01000102030405060708090a0b3c702ef0e032ed2f7b7c13c8e21adf348a603fc66ef20f875996825c999dc5f110d66cf89f88d3cc7f0518ed1c5e3f18" + } + }, + "expected": { + "status": "unreadable", + "reason": "badTag" + } +} diff --git a/forge-contracts/vectors/sealed_board__open_no_epoch.json b/forge-contracts/vectors/sealed_board__open_no_epoch.json new file mode 100644 index 000000000..1658a4f34 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_no_epoch.json @@ -0,0 +1,34 @@ +{ + "name": "open_no_epoch", + "description": "an epoch without an anchor does not exist: Unreadable(NoEpoch).", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" + }, + "anchors": { + "1": { + "id": "723e4415b140d11aae49ab4d7cbf0e3f418bb90092a5ab040d47602af4ba5a86", + "height": 1000 + } + }, + "members": [] + }, + "doc": { + "type": "board", + "key": 7, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 0, + "plaintext": false, + "enc": "01000102030405060708090a0b3e7028a0ac5388143e0c35b3b050df789b274eea479160eb2cfbec2fbba79e8a330954a9e8700f356020378f2350e347a9d8bd0f55aac03fe2ae2265e98dfa589874658be2f70d3a8102d8736fdb4c99f93726ec567354e3eb4cf7685f5b3950e9c00e6a81460d91e36cde8ada3ad90c548e031d6e78adaa21612b6862e4008ef93596fbe90429874f25150568ec0e65" + } + }, + "expected": { + "status": "unreadable", + "reason": "noEpoch" + } +} diff --git a/forge-contracts/vectors/sealed_board__open_no_key.json b/forge-contracts/vectors/sealed_board__open_no_key.json new file mode 100644 index 000000000..0b5cec1d5 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_no_key.json @@ -0,0 +1,38 @@ +{ + "name": "open_no_key", + "description": "epoch 0 exists but the reader holds only K_1: Unreadable(NoKey).", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "1": "202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + }, + "1": { + "id": "723e4415b140d11aae49ab4d7cbf0e3f418bb90092a5ab040d47602af4ba5a86", + "height": 1000 + } + }, + "members": [] + }, + "doc": { + "type": "board", + "key": 7, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 0, + "plaintext": false, + "enc": "01000102030405060708090a0b3e7028a0ac5388143e0c35b3b050df789b274eea479160eb2cfbec2fbba79e8a330954a9e8700f356020378f2350e347a9d8bd0f55aac03fe2ae2265e98dfa589874658be2f70d3a8102d8736fdb4c99f93726ec567354e3eb4cf7685f5b3950e9c00e6a81460d91e36cde8ada3ad90c548e031d6e78adaa21612b6862e4008ef93596fbe90429874f25150568ec0e65" + } + }, + "expected": { + "status": "unreadable", + "reason": "noKey" + } +} diff --git a/forge-contracts/vectors/sealed_board__open_other_owner.json b/forge-contracts/vectors/sealed_board__open_other_owner.json new file mode 100644 index 000000000..254a9600c --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_other_owner.json @@ -0,0 +1,34 @@ +{ + "name": "open_other_owner", + "description": "the AD binds $ownerId: another member cannot re-post this enc as theirs.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + } + }, + "members": [] + }, + "doc": { + "type": "board", + "key": 7, + "ownerId": "2323232323232323232323232323232323232323232323232323232323232323", + "epoch": 0, + "plaintext": false, + "enc": "01000102030405060708090a0b3e7028a0ac5388143e0c35b3b050df789b274eea479160eb2cfbec2fbba79e8a330954a9e8700f356020378f2350e347a9d8bd0f55aac03fe2ae2265e98dfa589874658be2f70d3a8102d8736fdb4c99f93726ec567354e3eb4cf7685f5b3950e9c00e6a81460d91e36cde8ada3ad90c548e031d6e78adaa21612b6862e4008ef93596fbe90429874f25150568ec0e65" + } + }, + "expected": { + "status": "unreadable", + "reason": "badTag" + } +} diff --git a/forge-contracts/vectors/sealed_board__open_plaintext_beside_enc.json b/forge-contracts/vectors/sealed_board__open_plaintext_beside_enc.json new file mode 100644 index 000000000..089a0a49b --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_plaintext_beside_enc.json @@ -0,0 +1,33 @@ +{ + "name": "open_plaintext_beside_enc", + "description": "a sealed board that also carries a plaintext name or spec is malformed (the contract's noPlain refuses it; a reader does too).", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + } + }, + "members": [] + }, + "doc": { + "type": "board", + "key": 7, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 0, + "plaintext": true, + "enc": "01000102030405060708090a0b3e7028a0ac5388143e0c35b3b050df789b274eea479160eb2cfbec2fbba79e8a330954a9e8700f356020378f2350e347a9d8bd0f55aac03fe2ae2265e98dfa589874658be2f70d3a8102d8736fdb4c99f93726ec567354e3eb4cf7685f5b3950e9c00e6a81460d91e36cde8ada3ad90c548e031d6e78adaa21612b6862e4008ef93596fbe90429874f25150568ec0e65" + } + }, + "expected": { + "status": "malformed" + } +} diff --git a/forge-contracts/vectors/sealed_board__open_private_without_enc.json b/forge-contracts/vectors/sealed_board__open_private_without_enc.json new file mode 100644 index 000000000..20c4e5b7d --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_private_without_enc.json @@ -0,0 +1,32 @@ +{ + "name": "open_private_without_enc", + "description": "a private repository's board without enc is malformed: its readers read only sealed boards.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + } + }, + "members": [] + }, + "doc": { + "type": "board", + "key": 7, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 0, + "plaintext": false + } + }, + "expected": { + "status": "malformed" + } +} diff --git a/forge-contracts/vectors/sealed_board__open_short_enc.json b/forge-contracts/vectors/sealed_board__open_short_enc.json new file mode 100644 index 000000000..0b8f6f99b --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_short_enc.json @@ -0,0 +1,33 @@ +{ + "name": "open_short_enc", + "description": "an enc shorter than 29 bytes is malformed before any key is used.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + } + }, + "members": [] + }, + "doc": { + "type": "board", + "key": 7, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 0, + "plaintext": false, + "enc": "01000102030405060708090a0b3e7028a0ac5388143e0c35b3b050df" + } + }, + "expected": { + "status": "malformed" + } +} diff --git a/forge-contracts/vectors/sealed_board__open_superseded_epoch_still_opens.json b/forge-contracts/vectors/sealed_board__open_superseded_epoch_still_opens.json new file mode 100644 index 000000000..95a55f6ba --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_superseded_epoch_still_opens.json @@ -0,0 +1,42 @@ +{ + "name": "open_superseded_epoch_still_opens", + "description": "a board under superseded epoch 0 by a member removed since still opens: both types are member-gated at consensus on every write, so the height part of the late rule (§8.2) does not apply.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", + "1": "202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + }, + "1": { + "id": "723e4415b140d11aae49ab4d7cbf0e3f418bb90092a5ab040d47602af4ba5a86", + "height": 1000 + } + }, + "members": [] + }, + "doc": { + "type": "board", + "key": 7, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 0, + "plaintext": false, + "enc": "01000102030405060708090a0b3e7028a0ac5388143e0c35b3b050df789b274eea479160eb2cfbec2fbba79e8a330954a9e8700f356020378f2350e347a9d8bd0f55aac03fe2ae2265e98dfa589874658be2f70d3a8102d8736fdb4c99f93726ec567354e3eb4cf7685f5b3950e9c00e6a81460d91e36cde8ada3ad90c548e031d6e78adaa21612b6862e4008ef93596fbe90429874f25150568ec0e65" + } + }, + "expected": { + "status": "readable", + "fields": { + "name": "Roadmap", + "spec": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"In progress\"},{\"id\":3,\"name\":\"Done\"}],\"def\":1,\"done\":3}" + } + } +} diff --git a/forge-contracts/vectors/sealed_board__open_tlv_board_tag_in_card.json b/forge-contracts/vectors/sealed_board__open_tlv_board_tag_in_card.json new file mode 100644 index 000000000..721a56dae --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_tlv_board_tag_in_card.json @@ -0,0 +1,34 @@ +{ + "name": "open_tlv_board_tag_in_card", + "description": "a board's tag (33) in a card is malformed.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + } + }, + "members": [] + }, + "doc": { + "type": "card", + "board": 7, + "item": "4444444444444444444444444444444444444444444444444444444444444444", + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 0, + "plaintext": false, + "enc": "01000102030405060708090a0b3f702d89be7e5e98ea29e6753e65d450bcfb37696e" + } + }, + "expected": { + "status": "malformed" + } +} diff --git a/forge-contracts/vectors/sealed_board__open_tlv_board_without_spec.json b/forge-contracts/vectors/sealed_board__open_tlv_board_without_spec.json new file mode 100644 index 000000000..c8b954947 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_tlv_board_without_spec.json @@ -0,0 +1,33 @@ +{ + "name": "open_tlv_board_without_spec", + "description": "a board needs its definition.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + } + }, + "members": [] + }, + "doc": { + "type": "board", + "key": 7, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 0, + "plaintext": false, + "enc": "01000102030405060708090a0b3e7028a0ac5388143e0c6d0e111c646bfbea8f0001fc34e70d9a" + } + }, + "expected": { + "status": "malformed" + } +} diff --git a/forge-contracts/vectors/sealed_board__open_tlv_col_two_bytes.json b/forge-contracts/vectors/sealed_board__open_tlv_col_two_bytes.json new file mode 100644 index 000000000..3d3719f9a --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_tlv_col_two_bytes.json @@ -0,0 +1,34 @@ +{ + "name": "open_tlv_col_two_bytes", + "description": "a column is exactly one byte.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + } + }, + "members": [] + }, + "doc": { + "type": "card", + "board": 7, + "item": "4444444444444444444444444444444444444444444444444444444444444444", + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 0, + "plaintext": false, + "enc": "01000102030405060708090a0b3c702df2c2d049d7d8a00cc02cff3001588c0bae5a" + } + }, + "expected": { + "status": "malformed" + } +} diff --git a/forge-contracts/vectors/sealed_board__open_tlv_content_tag_in_board.json b/forge-contracts/vectors/sealed_board__open_tlv_content_tag_in_board.json new file mode 100644 index 000000000..25bf0cfd0 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_tlv_content_tag_in_board.json @@ -0,0 +1,33 @@ +{ + "name": "open_tlv_content_tag_in_board", + "description": "another kind's tag (2, a body) in a board is malformed.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + } + }, + "members": [] + }, + "doc": { + "type": "board", + "key": 7, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 0, + "plaintext": false, + "enc": "01000102030405060708090a0b1c702e8ae332eb2b301d70dea15bdc0ec9665db047c83eab7bf5ed30ecf0ab82335a6bf0f0284735347076c86f0bac76e486f07947e2d43ff6e67b7db2c5fa0ccb3522c7b9b821769b50e37228d95b85ed673eb35e7340abb254ad205f0f6b11ae8c5525a00b59d6857eedc3da23e14654d057576e26f3e866277e357a863abd577bfdd067ea604e8b54bb3d810534a994" + } + }, + "expected": { + "status": "malformed" + } +} diff --git a/forge-contracts/vectors/sealed_board__open_tlv_empty_rank_absent.json b/forge-contracts/vectors/sealed_board__open_tlv_empty_rank_absent.json new file mode 100644 index 000000000..d231cc4e7 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_tlv_empty_rank_absent.json @@ -0,0 +1,37 @@ +{ + "name": "open_tlv_empty_rank_absent", + "description": "a zero-length record of a field with minLength 1 counts as absent.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + } + }, + "members": [] + }, + "doc": { + "type": "card", + "board": 7, + "item": "4444444444444444444444444444444444444444444444444444444444444444", + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 0, + "plaintext": false, + "enc": "01000102030405060708090a0b3c702ef3e032ecc89844c25f0db9e7c7dc54fba36c1b7d" + } + }, + "expected": { + "status": "readable", + "fields": { + "col": 1 + } + } +} diff --git a/forge-contracts/vectors/sealed_board__open_tlv_extension_skipped.json b/forge-contracts/vectors/sealed_board__open_tlv_extension_skipped.json new file mode 100644 index 000000000..027e7e410 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_tlv_extension_skipped.json @@ -0,0 +1,37 @@ +{ + "name": "open_tlv_extension_skipped", + "description": "tags 64-255 are extensions: skipped.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + } + }, + "members": [] + }, + "doc": { + "type": "card", + "board": 7, + "item": "4444444444444444444444444444444444444444444444444444444444444444", + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 0, + "plaintext": false, + "enc": "01000102030405060708090a0b3c702ef38532e9153e0871c12c6981e59ce12f6bff6372fa76f91d46" + } + }, + "expected": { + "status": "readable", + "fields": { + "col": 1 + } + } +} diff --git a/forge-contracts/vectors/sealed_board__open_tlv_out_of_order.json b/forge-contracts/vectors/sealed_board__open_tlv_out_of_order.json new file mode 100644 index 000000000..17e023542 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_tlv_out_of_order.json @@ -0,0 +1,34 @@ +{ + "name": "open_tlv_out_of_order", + "description": "records out of order (rank before column) are malformed.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + } + }, + "members": [] + }, + "doc": { + "type": "card", + "board": 7, + "item": "4444444444444444444444444444444444444444444444444444444444444444", + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 0, + "plaintext": false, + "enc": "01000102030405060708090a0b3d702ea4e132ed7b64759ab231e7476ee3c341ce6aee97a7" + } + }, + "expected": { + "status": "malformed" + } +} diff --git a/forge-contracts/vectors/sealed_board__open_tlv_rank_trailing_zero.json b/forge-contracts/vectors/sealed_board__open_tlv_rank_trailing_zero.json new file mode 100644 index 000000000..1ec20a496 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_tlv_rank_trailing_zero.json @@ -0,0 +1,34 @@ +{ + "name": "open_tlv_rank_trailing_zero", + "description": "a sealed rank ending in 0 is malformed, as the plaintext pattern refuses it.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + } + }, + "members": [] + }, + "doc": { + "type": "card", + "board": 7, + "item": "4444444444444444444444444444444444444444444444444444444444444444", + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 0, + "plaintext": false, + "enc": "01000102030405060708090a0b3d702da4f3e1405201c7d6dfcd41afa1c599137d50" + } + }, + "expected": { + "status": "malformed" + } +} diff --git a/forge-contracts/vectors/sealed_board__open_tlv_repeated.json b/forge-contracts/vectors/sealed_board__open_tlv_repeated.json new file mode 100644 index 000000000..764f00654 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_tlv_repeated.json @@ -0,0 +1,34 @@ +{ + "name": "open_tlv_repeated", + "description": "a repeated record is malformed.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + } + }, + "members": [] + }, + "doc": { + "type": "card", + "board": 7, + "item": "4444444444444444444444444444444444444444444444444444444444444444", + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 0, + "plaintext": false, + "enc": "01000102030405060708090a0b3c702ef0e132ed7a8689b616e00dc8cd9c80685cd8592f96" + } + }, + "expected": { + "status": "malformed" + } +} diff --git a/forge-contracts/vectors/sealed_board__open_tlv_truncated.json b/forge-contracts/vectors/sealed_board__open_tlv_truncated.json new file mode 100644 index 000000000..44ad26ec8 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_tlv_truncated.json @@ -0,0 +1,33 @@ +{ + "name": "open_tlv_truncated", + "description": "a record running past the end is malformed.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + } + }, + "members": [] + }, + "doc": { + "type": "board", + "key": 7, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 0, + "plaintext": false, + "enc": "01000102030405060708090a0b3e7028a0ac5388143e0c35b3c95080ca7df70d3e0b8a52196338fe006d8126" + } + }, + "expected": { + "status": "malformed" + } +} diff --git a/forge-contracts/vectors/sealed_board__open_under_burned_epoch_by_member.json b/forge-contracts/vectors/sealed_board__open_under_burned_epoch_by_member.json new file mode 100644 index 000000000..d336f9392 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_under_burned_epoch_by_member.json @@ -0,0 +1,49 @@ +{ + "name": "open_under_burned_epoch_by_member", + "description": "the same card by a current member opens.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", + "1": "202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + }, + "1": { + "id": "723e4415b140d11aae49ab4d7cbf0e3f418bb90092a5ab040d47602af4ba5a86", + "height": 1000 + } + }, + "members": [ + "2222222222222222222222222222222222222222222222222222222222222222" + ], + "burned": [ + 1 + ] + }, + "doc": { + "type": "card", + "board": 7, + "item": "4444444444444444444444444444444444444444444444444444444444444444", + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 1, + "plaintext": false, + "enc": "01000102030405060708090a0bf4b9c25c37c4d769e14682b0ccdccae4610b48e8a993db7826ad0e56492935789535360f7d5587ddad23a7725e27e1bb" + } + }, + "expected": { + "status": "readable", + "fields": { + "col": 2, + "rank": "V", + "f": "{\"1\":3}" + } + } +} diff --git a/forge-contracts/vectors/sealed_board__open_under_burned_epoch_by_removed_member.json b/forge-contracts/vectors/sealed_board__open_under_burned_epoch_by_removed_member.json new file mode 100644 index 000000000..4282d7936 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_under_burned_epoch_by_removed_member.json @@ -0,0 +1,43 @@ +{ + "name": "open_under_burned_epoch_by_removed_member", + "description": "the burned clause of §8.2 still applies: a card under burned epoch 1 by someone who is no longer a member is Unreadable(Late).", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", + "1": "202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + }, + "1": { + "id": "723e4415b140d11aae49ab4d7cbf0e3f418bb90092a5ab040d47602af4ba5a86", + "height": 1000 + } + }, + "members": [], + "burned": [ + 1 + ] + }, + "doc": { + "type": "card", + "board": 7, + "item": "4444444444444444444444444444444444444444444444444444444444444444", + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 1, + "plaintext": false, + "enc": "01000102030405060708090a0bf4b9c25c37c4d769e14682b0ccdccae4610b48e8a993db7826ad0e56492935789535360f7d5587ddad23a7725e27e1bb" + } + }, + "expected": { + "status": "unreadable", + "reason": "late" + } +} diff --git a/forge-contracts/vectors/sealed_board__open_version_3.json b/forge-contracts/vectors/sealed_board__open_version_3.json new file mode 100644 index 000000000..f3ea173c7 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__open_version_3.json @@ -0,0 +1,34 @@ +{ + "name": "open_version_3", + "description": "a version other than 0x01 is a later client's (a public repository's members-only board): Unreadable(UnknownVersion), listed, never malformed.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "open", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "context": { + "keys": { + "0": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" + }, + "anchors": { + "0": { + "id": "d8789e13d97af4e288d46cadf47488315539d063487e8855778ef2c990068926", + "height": 10 + } + }, + "members": [] + }, + "doc": { + "type": "board", + "key": 7, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "epoch": 0, + "plaintext": false, + "enc": "03000102030405060708090a0b3e7028a0ac5388143e0c35b3b050df789b274eea479160eb2cfbec2fbba79e8a330954a9e8700f356020378f2350e347a9d8bd0f55aac03fe2ae2265e98dfa589874658be2f70d3a8102d8736fdb4c99f93726ec567354e3eb4cf7685f5b3950e9c00e6a81460d91e36cde8ada3ad90c548e031d6e78adaa21612b6862e4008ef93596fbe90429874f25150568ec0e65" + } + }, + "expected": { + "status": "unreadable", + "reason": "unknownVersion" + } +} diff --git a/forge-contracts/vectors/sealed_board__seal_board.json b/forge-contracts/vectors/sealed_board__seal_board.json new file mode 100644 index 000000000..07d2d1132 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__seal_board.json @@ -0,0 +1,27 @@ +{ + "name": "seal_board", + "description": "a board under epoch 0: its name (TLV 32) and definition (33), padded to 32 bytes; the AD binds u32(key).", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "seal", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "key": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", + "epoch": 0, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "nonce": "000102030405060708090a0b", + "doc": { + "type": "board", + "key": 7 + }, + "fields": { + "name": "Roadmap", + "spec": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"In progress\"},{\"id\":3,\"name\":\"Done\"}],\"def\":1,\"done\":3}" + } + }, + "expected": { + "ad": "646173682d666f7267652f76322f646f6300011111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222200000000626f6172640000000007", + "tlv": "200007526f61646d61702100707b2276223a312c22636f6c756d6e73223a5b7b226964223a312c226e616d65223a22546f646f227d2c7b226964223a322c226e616d65223a22496e2070726f6772657373227d2c7b226964223a332c226e616d65223a22446f6e65227d5d2c22646566223a312c22646f6e65223a337d400000", + "enc": "01000102030405060708090a0b3e7028a0ac5388143e0c35b3b050df789b274eea479160eb2cfbec2fbba79e8a330954a9e8700f356020378f2350e347a9d8bd0f55aac03fe2ae2265e98dfa589874658be2f70d3a8102d8736fdb4c99f93726ec567354e3eb4cf7685f5b3950e9c00e6a81460d91e36cde8ada3ad90c548e031d6e78adaa21612b6862e4008ef93596fbe90429874f25150568ec0e65" + } +} diff --git a/forge-contracts/vectors/sealed_board__seal_board_epoch1.json b/forge-contracts/vectors/sealed_board__seal_board_epoch1.json new file mode 100644 index 000000000..856c60615 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__seal_board_epoch1.json @@ -0,0 +1,27 @@ +{ + "name": "seal_board_epoch1", + "description": "the same board under epoch 1: another key, another epoch in the AD.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "seal", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "key": "202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f", + "epoch": 1, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "nonce": "000102030405060708090a0b", + "doc": { + "type": "board", + "key": 7 + }, + "fields": { + "name": "Roadmap", + "spec": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"In progress\"},{\"id\":3,\"name\":\"Done\"}],\"def\":1,\"done\":3}" + } + }, + "expected": { + "ad": "646173682d666f7267652f76322f646f6300011111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222200000001626f6172640000000007", + "tlv": "200007526f61646d61702100707b2276223a312c22636f6c756d6e73223a5b7b226964223a312c226e616d65223a22546f646f227d2c7b226964223a322c226e616d65223a22496e2070726f6772657373227d2c7b226964223a332c226e616d65223a22446f6e65227d5d2c22646566223a312c22646f6e65223a337d400000", + "enc": "01000102030405060708090a0bf6b9c40c7ba5b252a436a4cb9e96caa8704c39c480f0b41453c060256b136e03f7b379e6e39a1009d28adb1b426b75caef9efb7b0a350effcc3b561ea101230a9bd159c631199f28bdccde8822b545fc1cb5cdf13893f701c0a0271eb85ab07cf9c1c7ee3cd57420ec2330ba92c188a7d2d77afd8712107516ce80db327fa3bade35dd1731e53a6240182aaa50563d11" + } +} diff --git a/forge-contracts/vectors/sealed_board__seal_board_key_max.json b/forge-contracts/vectors/sealed_board__seal_board_key_max.json new file mode 100644 index 000000000..6b6d169e8 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__seal_board_key_max.json @@ -0,0 +1,27 @@ +{ + "name": "seal_board_key_max", + "description": "the largest key, 4294967295.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "seal", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "key": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", + "epoch": 0, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "nonce": "000102030405060708090a0b", + "doc": { + "type": "board", + "key": 4294967295 + }, + "fields": { + "name": "Ops", + "spec": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"}]}" + } + }, + "expected": { + "ad": "646173682d666f7267652f76322f646f6300011111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222200000000626f61726400ffffffff", + "tlv": "2000034f707321002a7b2276223a312c22636f6c756d6e73223a5b7b226964223a312c226e616d65223a22546f646f227d5d7d40000a00000000000000000000", + "enc": "01000102030405060708090a0b3e702cbdb341cd79750736c5e211cc229b7e10aa109f61f47bacd927bbf4a1d32b511ca9bc204e722c7b78be6e0eae31bbe1af6d288cbb1d8bca005fdba1d836f54b660aca5699ac713627493305f0e8" + } +} diff --git a/forge-contracts/vectors/sealed_board__seal_board_key_zero.json b/forge-contracts/vectors/sealed_board__seal_board_key_zero.json new file mode 100644 index 000000000..d30b446b7 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__seal_board_key_zero.json @@ -0,0 +1,25 @@ +{ + "name": "seal_board_key_zero", + "description": "key 0 is not a board key.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "seal", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "key": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", + "epoch": 0, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "nonce": "000102030405060708090a0b", + "doc": { + "type": "board", + "key": 0 + }, + "fields": { + "name": "Zero", + "spec": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"In progress\"},{\"id\":3,\"name\":\"Done\"}],\"def\":1,\"done\":3}" + } + }, + "expected": { + "error": "malformed" + } +} diff --git a/forge-contracts/vectors/sealed_board__seal_board_name_63_chars.json b/forge-contracts/vectors/sealed_board__seal_board_name_63_chars.json new file mode 100644 index 000000000..3c70c9de0 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__seal_board_name_63_chars.json @@ -0,0 +1,27 @@ +{ + "name": "seal_board_name_63_chars", + "description": "a name at its 63-character cap.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "seal", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "key": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", + "epoch": 0, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "nonce": "000102030405060708090a0b", + "doc": { + "type": "board", + "key": 7 + }, + "fields": { + "name": "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn", + "spec": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"In progress\"},{\"id\":3,\"name\":\"Done\"}],\"def\":1,\"done\":3}" + } + }, + "expected": { + "ad": "646173682d666f7267652f76322f646f6300011111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222200000000626f6172640000000007", + "tlv": "20003f6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e6e2100707b2276223a312c22636f6c756d6e73223a5b7b226964223a312c226e616d65223a22546f646f227d2c7b226964223a322c226e616d65223a22496e2070726f6772657373227d2c7b226964223a332c226e616d65223a22446f6e65227d5d2c22646566223a312c22646f6e65223a337d4000080000000000000000", + "enc": "01000102030405060708090a0b3e70109cad5c821731127addae459360d77311a80b9c61e937f8ec32f7f3ab9f7f0e5ee5bc2f4d79602f34846f04af7da8d2bc4346e8d573e5a46e31b5cfb658977721a9a8ae662283489b302aca4686ff7835b30f6b66fceb1fa0664704741fe283592de71341a0ae75ec848572c7481fd0100b7e30e0aa252e7479258649e00a67b63cbfdf48ade0cec965921838ac2f45a1d2485c767e00befa6ee6a67ed175ec6e8270aec9e03450bddf03fc9ce66c4d5e7db3d503d560c4e46d30559f32af7d62903e130943fc567d3d7746e1be" + } +} diff --git a/forge-contracts/vectors/sealed_board__seal_board_name_64_chars.json b/forge-contracts/vectors/sealed_board__seal_board_name_64_chars.json new file mode 100644 index 000000000..36d9fe00c --- /dev/null +++ b/forge-contracts/vectors/sealed_board__seal_board_name_64_chars.json @@ -0,0 +1,25 @@ +{ + "name": "seal_board_name_64_chars", + "description": "a name over 63 characters is refused before sealing.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "seal", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "key": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", + "epoch": 0, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "nonce": "000102030405060708090a0b", + "doc": { + "type": "board", + "key": 7 + }, + "fields": { + "name": "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn", + "spec": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"In progress\"},{\"id\":3,\"name\":\"Done\"}],\"def\":1,\"done\":3}" + } + }, + "expected": { + "error": "malformed" + } +} diff --git a/forge-contracts/vectors/sealed_board__seal_board_name_blank.json b/forge-contracts/vectors/sealed_board__seal_board_name_blank.json new file mode 100644 index 000000000..97e2f167f --- /dev/null +++ b/forge-contracts/vectors/sealed_board__seal_board_name_blank.json @@ -0,0 +1,25 @@ +{ + "name": "seal_board_name_blank", + "description": "a name of only white space is refused (the schema pattern needs a visible character).", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "seal", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "key": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", + "epoch": 0, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "nonce": "000102030405060708090a0b", + "doc": { + "type": "board", + "key": 7 + }, + "fields": { + "name": " ", + "spec": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"In progress\"},{\"id\":3,\"name\":\"Done\"}],\"def\":1,\"done\":3}" + } + }, + "expected": { + "error": "malformed" + } +} diff --git a/forge-contracts/vectors/sealed_board__seal_board_name_control.json b/forge-contracts/vectors/sealed_board__seal_board_name_control.json new file mode 100644 index 000000000..63e2253b3 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__seal_board_name_control.json @@ -0,0 +1,25 @@ +{ + "name": "seal_board_name_control", + "description": "a name with a control character is refused.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "seal", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "key": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", + "epoch": 0, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "nonce": "000102030405060708090a0b", + "doc": { + "type": "board", + "key": 7 + }, + "fields": { + "name": "a\tb", + "spec": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"In progress\"},{\"id\":3,\"name\":\"Done\"}],\"def\":1,\"done\":3}" + } + }, + "expected": { + "error": "malformed" + } +} diff --git a/forge-contracts/vectors/sealed_board__seal_board_spec_4096_bytes.json b/forge-contracts/vectors/sealed_board__seal_board_spec_4096_bytes.json new file mode 100644 index 000000000..5f9bd7b3b --- /dev/null +++ b/forge-contracts/vectors/sealed_board__seal_board_spec_4096_bytes.json @@ -0,0 +1,27 @@ +{ + "name": "seal_board_spec_4096_bytes", + "description": "a definition at its 4096-byte cap (the TLV does not judge its JSON: the board rules do).", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "seal", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "key": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", + "epoch": 0, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "nonce": "000102030405060708090a0b", + "doc": { + "type": "board", + "key": 7 + }, + "fields": { + "name": "Big", + "spec": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + } + }, + "expected": { + "ad": "646173682d666f7267652f76322f646f6300011111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222200000000626f6172640000000007", + "tlv": "200003426967211000787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878784000140000000000000000000000000000000000000000", + "enc": "01000102030405060708090a0b3e702cb0aa55cd695f046ccbb8538576c16507be1d8a77ff21eefa24e1e5bd89691848f3aa395b6f763922927912b96bbec4aa5550fec365f3b27827a3d9a04e816178d1a0ad3c2cd90ad26470d15192f26d23b8552945ffb10ebc3c054d2045f49a4c30bd511b8cb969fbde8026c4120ecc4a493464babc3c3b692367dc78f6526fbc2ba0d555a6eb94cc31914229b07507ea86124a6f6b1de4b834dab168cc2fe94bd62ab2d4fe6e12f48b59e08bf071171c36b6ed7ba518bc9c15482de74a6558453af589dbac67849bf671b613c58228dbf1828694a295b3d3f98b0ada7652c67205384291ab25c69ae87677a695ef32a579d40ae32ca1384431979a254a7705796be2f87bbaa8cba0f1bd96a7edcda9678f26df894267a4fc360f88d7572b843f5f649117c3d2ec33909979217d058add006370839afe0e61cf6ac55c1415db5bd22b97942fe569060f551bdc200b06f0c6c3da0c4317548c2c417449d29a18440caf0f600ac4141edb59496f81a54c98a60746b380b704e1a367941e1cfd31c0d04d3c4d5f76c805970464d81776212149ab122c7e42383c01d2c262f8fe4151ac495f67811f7f7a9d471d8f0d0e03d207f0781fea8f96d47f8c0f1ff41254989a08c1b42a43232fa840feaa434f124c2c4464f47960c98ae454efd86020d2417006cab626e68b5c17be872d4f3b5c401b64f5eb8f260c6327086f3566c17e0d4aa6d0be8d7c2d2fa27236e606df8b2c8ae85286927ea9a9c63c0750de1845bff3aec8c664fc6b2a7710d50c251e25a23852b3c2cfc725906e2853f22727ccc74dc091d370f083dd8aa82fef888930721048aec6ae5988e5089aec21887d8e562be838690c0bd5d93cbb42edebf99d41a0c56c1e3cc4a7ff0eacf99e2b5de52ce5687eb924ce781639c8967461ea6d2b3bce667289be355fd91e037175bcbfe7c71b06b466b3d19ffe7ee879a9e4f0c993d1ab5c19b43e07383c360e525b370bfd0bac884519329bda63c723c15d1c8611bbff6c102d1ecf009f244c92b7e12eb2d2ab2de6711d5d8419594d7e3223676df27866d4f5b17c53b8c2d18918fc861827f2502bc6425ed22d4f08c442a331adf1a23b1e3e901ca8e3eb312faec851e5a53a394d978dbb5791f4972da9bc7d800b4ecbeb0a8bd67f1a0e25ca503fc257271f77f07c6a38aca145bcaef49e6a39c028b8dda67dba79e39a73c494b6613ad5febbfc6ad8d5002b466f89ec2d20fb2a72d2c0771fc9f625895c071ba2a993135817596f9ef9e167ff1a8dc19eab1eacb072000d9c478bb54522da09b87368e90ccb926fb6769225e94e95ec8d40eaaa29e39801b2e0f3fc4a5ecb89bb0a5750e0a234ed95d6e5170dcd736b6894822a05a18a21d46a5e358c61ed2f47f8d15674a96befcceea342598ce918c41b2e04e229db0c421e269d173810f6d621f3881a05f081e9a8119378ce7e04aba48bde12eff397b82963e9b5a81fbd72cb5dd5d56b756e0d5be995aeedbc6c480f3ab63c85e80f1ea7b96a1c60f07178f5fd4f8764aa1166cb2742de0c49015cae1c1938bd8d2230c347e150456e68a872c7b81e5ed4cc607eb3adefb0c9f12edbf498ee77b50d33e3e9e6afa370cf9d9b1b3450bfc31214a15daeda5707eb7e1d38df89af671f29123e0446838e08c6479ce5cf6e0f447081e9a40b5f2aaffef45416ab6161605bda4b4087b4fca29d48e884388412db8c6135d3cf8319f85920e2c8cd08e0888a07c22a0167e61ad51938731c5a06f96ccab164e4cebf40d6a939e274bdb8b1a42c73f30678e7988425102c5a0eb7fe06cd9b921b271a77c97741783f6ddc9344b9335316e70df89897587d442410a57d05f464d9033db711d71d5d22c2379772843900992732e5b0e972dcf86c28662d3ba93b32716e5f8bf2378a1f0c7f29a653bc0194e0a08e8321a037de8bd1942ea6b6a06ae23969a255be92c5a99680cf42b8c07ae1c77bd74566d3a16ade67249a00e30844da98835b972cf62bda82e5f92962ccf796caa3b07195e3d493c3cf6a0ee0fc873eaaab7ab5c765024da886a1a1fe99d9e0799edac7544292cdc4bd5fcf082d7c0db2844431d20f6f06676fe5682b897b7a05b0d5e9353af171ccae07a0dec463998b596d317b6d20b27997c2569db42ef325e60f1a232c3466943a0e22b81a685a0af9684be39af8b43639007c8d894f7af22388429b17ba986cf6f07f6979f2a4eaeeb6367739b56c69b8abb1be8c92358a14057fff5deecd203b14c582b4e668dfa02853ec521e9fc6498dfdfac16d3c4be19508fad32ed7dbec23276cb7d52e3a34658d298fe9b5450d4fa5e4b38ca520428ba8c605e381d63e32e6c6ea12318ac0916a81223f9d28fd5ef5d7a55165fd55fb0f59adf4dbf02de85904cf1d3c6737b97b1228ff81e17de12e39d5e0354585efc9915f6d8a2dbfd77ed38a6d006eb98f6c889e12930e2d800cad94f0daa759bda0a61ccc9460fdd6a6d87da41484b359d2a8c0b7bdd22a5b0ba2b418d6ceea955bfb8e7d7a782e5fdf12aafaffe4c8a83e93f21232f085d23cd5294e065bbea7114fa6bd665876e6b3cedd406be8bab50c8ce0c6a5b0acd657ac47b08efd182610bd07c8ff74126dc360944151d015f629309cfba7adce894a7ee722ad12c9ca82e98a5df477b75d570811d1db5ddb58e4fc16b87ab00b6b74c2a5c56748c1a4759e607259de4109276ed95a7db08597282fcd390d860c0b47e4b611ca6ed8b894ca4940e8a0e9d7765e417a2ee3c6ba64d90783d8c851ad95c0ea2720a0dfce4a0fdeddb867b3f661878b42a50ca46663ad75234f710c75e6ebd150a13f54ca809a30dc9a032f577c26c24372910b83f8c7aa5042461c08a3f733d40eba001bc0b36dd48f87b24c0223d36e09c63d234c6b2d6ef6a7f34ef4167cf0287e76a37e1495f0e319b15692d3f38c6b2928640228f840ee391c59c8821f773509fc2b8f663864fe2e5f98c8a56c67c49775e4b268d655a0a273c75339bec841dd0427460bf00931da626369f7fed8feddbd0f9d25d9268733bfcb5915f6862958220de690090a2b7021c9d76323434152e3820d5a84bd7f208779642ac9f2e1bfb2ab00585970ee7b6fbaee3b8a21db864a8ee56cdd121248fe27b6f29a34947353c38b873fbda2994134f16cdf440ecfd01943bf3941b03ca45cd7d96db0217028eba720fe8bb37ec0067cf3988a2042d714cc10022858441f183d2abbc4bbb0df42399b8cfcb5a0cab05f1b937796917c686af48e3e5c3a63a637f7f440052d9d0e8b095a92f61a4ccb141d7d33d43923abfbc28ca80179494c12e2e2c00e3f6679ccaffca440e78ac740ca984d5909ef0078638c900e6a905911a59a4439f3a46dc41a348181f2f7657411ee761c53ad77218b67beef4dd72f8a53c4b28838872f2816dbf2c464d3422710581b0554728fa672ca2a74982b97fcc808ba8221ccb7a2b3e2691c7b8cfdf15c5a002762edeba9a5ca8dff2fd406458ade9f05ad54867f3b354f0c79001d05568bac25b30bc4b06c3ac12d5fd917d11e045cdeecbb0d36a702f933e57a9ff3c128696cb351bdd1aac5751c5ba0d10477f63f90ac4e1bb553a1f37a09904e49b1f0337be7ce315d74aa2f353eab8e5aa1823000ae3f6647ef9532c82173d104a7440e5eb76afbaf2d1bc594a0a1ea79917b0bef09532f0096c0a757f9a7656abc62c8b6175e0664a27fcb426ad494382609ca37b86f0f742a8be05905542b47470eeb427ae89d5d3af4c00262018f057ff2b984d66bafcfa43cc8abee4e15ec7a9f70894fb4553574d7963b9dae9fc13e126091d4fc1a98c85fe6c051d7ad1cd6fe0f604aab18cad2e85d71464733c9efdc7f4104931dd51f936bf422aaac19bae56b324e9453edbf45015a59454c5ff738bc3ba78b8a4f5f6af4743a501dc759c2623a7cc389b7defa29c9d67f103cc38660f0739aff954e566bee85a82e1afbc9159331a4956abd92b8f87c4203b91c7ed1fe4ee49d1b2e7d409abda8bf61defec98ff21d00b0f3c0fced3ef9f8535078d50b34083500ae7d57f4ca61a598f7075ca95a545560c39b1d905e921589d1ee7e7f8a240ee853ce001ba20b926c0a68b4a6ac79e177669bf3b078247bd575c6b3e641f74339d90cfec7a772b0c4210b73e48f712e088d59a62c490de2564b328b86566f21c8b099375c2eaa6afa914d0bbd0ce10383b5af3e34560c8413fe2e8b9e4bb00760be643a13874fe13952e73f8112246925e304dc7fdba0e11696b73fc5115463446cbaafc0289292468544014cb4d51c2efb37b631fd0bd6613ba86063680e82cccff91934c30cd65015cecc1e7583fd998f5a221738585c7d264a00e20f2f07914f5594bafba77d94de7e8b6fb68a2645373c1c1814b23b507eb56402a1a4cc849d3e88e2a92bb7aa217b82f1baa63423615b4060203777fadb829649171b6635399ebea8f786db358ffcd903f02cd2e38bbb907ada8e4b798d07e34c0f8030df6d8b8be53551e8d1863e7f74123eae66e1f598617418142e4b44751cd50bcc1fef9f47f0fa8099615439cd4cddc580fdd23419459f6f95cfaee98227e57332ad6a4a4e92b43f442a5087f19ba315db5e263b50cc592981293a7976ec6428cf2d48bf6770ad1f16a700fbd63fa42600f8f79cf0cfe99eeb11598770490b1b1bdf33b269dfe4c0ebb689e2be8694f90ef1b5a15b4559bab0081e7ddea63fa476a21932ff355a06964cde6ea135a005d5f85d6f396f05198e3496b7a5b37b79f634ecf08416fcce9575575b61fed1af00dbed2f119cb9e164582e738b9131c3d59d2af2f6a76c905f9e880b15892161dda3d7cd92a24e80264a3ed54c1f73c95c81b7143256d4c084bae8f5edfdeb8d1f83f4a42182c29338083e1679aec346597097c31b3198b989bd09dc9018bf10c1128cc033e1026e6f206c18972c1e81581ef6300977f2145f83095e2b9c931a348158106dd06667ab90cb57e791eca5a8c73bc7c4ddbda92e1364ce3ece58a6fc2444fd36a87d359b16a24c46b0715cc18f990b3752b83b82bf03471a1b16ab3a4065f35db3337613ea1dabc818ebf72d520d7738d2586dbdf704f27804c8fbcc84ba8e5771c328975bb6d23d7ddb8ce7c039d57a4e9d03d57516dcddef333aeef22d50e5eff63152e497540a97ac0f8b34e89a054a74bc94203909db67f3de81635e8b8b675e371c52065d2a62e60a799cbf40ce6a99d5db9aae2492142abbe9799497243c250539cc690aa0081712bc1ea7dbd9ab9f1d9dcedb1b86cf139736f7907b1d4f8ca5341770de1f2649bb904f812b437e0f7cc801de8ccbaaa9b88710b3b7c3d5857276cefb3af4ed17b9e817c0d4fc5bc0a2b540bc3496d4342abbc7e7ca799b9926459e8aceae395eadbeda4d29567ac8cb3ab4374c9a02529d15876d72167cad0e4d580fb318d6bee8eecef1bf402ae80b79835b8d86c48ae67ef30a77b359226501334b7347d44560b7f7bae34fb860d01fcb6bd53c34d6a007230675cb8acc7ce3139a76253e0a8e993ce920a6c4890ae5bfb8073d6cfdc47028950b593db02d2b675d68b013e33d66e27b59a488c0a0d17977164471bfc38e9bed592f2242ee2445e423631d2915be620b6560589bbfc85343e4d0421de6d439ba2554e9df906749ef5c9b0781e215609b854925e3a5c3df07b4a2b3563492eb43527cdd735c585ecb0278fd454a9e1489e5a5befa14b61b5964dedda2be1ebccf3b2ebf2b1f9f5745160aa8c4f9c299ef9cb52edf36db1ef2aaf205d723dd39662359243b4b0d781e014b84fa1851b527b0b7226731cf65fde28d94" + } +} diff --git a/forge-contracts/vectors/sealed_board__seal_board_spec_4097_bytes.json b/forge-contracts/vectors/sealed_board__seal_board_spec_4097_bytes.json new file mode 100644 index 000000000..d9a709a42 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__seal_board_spec_4097_bytes.json @@ -0,0 +1,25 @@ +{ + "name": "seal_board_spec_4097_bytes", + "description": "a definition over 4096 bytes is refused.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "seal", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "key": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", + "epoch": 0, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "nonce": "000102030405060708090a0b", + "doc": { + "type": "board", + "key": 7 + }, + "fields": { + "name": "Big", + "spec": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + } + }, + "expected": { + "error": "malformed" + } +} diff --git a/forge-contracts/vectors/sealed_board__seal_board_spec_empty.json b/forge-contracts/vectors/sealed_board__seal_board_spec_empty.json new file mode 100644 index 000000000..922d2d6f4 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__seal_board_spec_empty.json @@ -0,0 +1,25 @@ +{ + "name": "seal_board_spec_empty", + "description": "a board needs a definition.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "seal", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "key": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", + "epoch": 0, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "nonce": "000102030405060708090a0b", + "doc": { + "type": "board", + "key": 7 + }, + "fields": { + "name": "Empty", + "spec": "" + } + }, + "expected": { + "error": "malformed" + } +} diff --git a/forge-contracts/vectors/sealed_board__seal_board_unicode_name.json b/forge-contracts/vectors/sealed_board__seal_board_unicode_name.json new file mode 100644 index 000000000..edc16e54d --- /dev/null +++ b/forge-contracts/vectors/sealed_board__seal_board_unicode_name.json @@ -0,0 +1,27 @@ +{ + "name": "seal_board_unicode_name", + "description": "a name of 11 characters and 13 bytes.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "seal", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "key": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", + "epoch": 0, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "nonce": "000102030405060708090a0b", + "doc": { + "type": "board", + "key": 7 + }, + "fields": { + "name": "Sprint ✨ 12", + "spec": "{\"v\":1,\"columns\":[{\"id\":1,\"name\":\"Todo\"},{\"id\":2,\"name\":\"In progress\"},{\"id\":3,\"name\":\"Done\"}],\"def\":1,\"done\":3}" + } + }, + "expected": { + "ad": "646173682d666f7267652f76322f646f6300011111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222200000000626f6172640000000007", + "tlv": "20000d537072696e7420e29ca82031322100707b2276223a312c22636f6c756d6e73223a5b7b226964223a312c226e616d65223a22546f646f227d2c7b226964223a322c226e616d65223a22496e2070726f6772657373227d2c7b226964223a332c226e616d65223a22446f6e65227d5d2c22646566223a312c22646f6e65223a337d40001a0000000000000000000000000000000000000000000000000000", + "enc": "01000102030405060708090a0b3e7022a1b34085172b5cf62f680bcc3c981d0fbd47842dbd68baa03ff6f1b09c7f1312b1893a017e6a6360db2d48af72abd9f0170ad2d479e4e87d73a083b152db233285fabb2539c450903e41c7099af87a3cb248224ea5b45abf6614517a07bfce1626a44406d6fb33c7c9963b9e172b981055297ae0fe756f333f70ca65ac1024b913d8b72dde93ecb449e93a51c80d7f92fe6a321713659cc04ca2c910b49d323483bd5499895b6fc40a8698d765" + } +} diff --git a/forge-contracts/vectors/sealed_board__seal_card.json b/forge-contracts/vectors/sealed_board__seal_card.json new file mode 100644 index 000000000..2d12bc398 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__seal_card.json @@ -0,0 +1,29 @@ +{ + "name": "seal_card", + "description": "a card: column (TLV 34, one byte), rank (35) and field values (36); the AD binds u32(board) and the item id.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "seal", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "key": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", + "epoch": 0, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "nonce": "000102030405060708090a0b", + "doc": { + "type": "card", + "board": 7, + "item": "4444444444444444444444444444444444444444444444444444444444444444" + }, + "fields": { + "col": 2, + "rank": "V", + "f": "{\"1\":3,\"2\":5}" + } + }, + "expected": { + "ad": "646173682d666f7267652f76322f646f63000111111111111111111111111111111111111111111111111111111111111111112222222222222222222222222222222222222222222222222222222222222222000000006361726400000000074444444444444444444444444444444444444444444444444444444444444444", + "tlv": "220001022300015624000d7b2231223a332c2232223a357d4000050000000000", + "enc": "01000102030405060708090a0b3c702ef0e032ed2f7b7c19c8e21adf348a315df447c83afa1996875c999dc5f1d8d144af701b281092db7a53cfc55ab7" + } +} diff --git a/forge-contracts/vectors/sealed_board__seal_card_col_256.json b/forge-contracts/vectors/sealed_board__seal_card_col_256.json new file mode 100644 index 000000000..414d2eb7d --- /dev/null +++ b/forge-contracts/vectors/sealed_board__seal_card_col_256.json @@ -0,0 +1,25 @@ +{ + "name": "seal_card_col_256", + "description": "a column is 0-255.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "seal", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "key": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", + "epoch": 0, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "nonce": "000102030405060708090a0b", + "doc": { + "type": "card", + "board": 7, + "item": "4444444444444444444444444444444444444444444444444444444444444444" + }, + "fields": { + "col": 256 + } + }, + "expected": { + "error": "malformed" + } +} diff --git a/forge-contracts/vectors/sealed_board__seal_card_col_zero.json b/forge-contracts/vectors/sealed_board__seal_card_col_zero.json new file mode 100644 index 000000000..c30c61382 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__seal_card_col_zero.json @@ -0,0 +1,27 @@ +{ + "name": "seal_card_col_zero", + "description": "column 0 (\"No status\") is written: one byte 0x00.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "seal", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "key": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", + "epoch": 0, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "nonce": "000102030405060708090a0b", + "doc": { + "type": "card", + "board": 7, + "item": "4444444444444444444444444444444444444444444444444444444444444444" + }, + "fields": { + "col": 0 + } + }, + "expected": { + "ad": "646173682d666f7267652f76322f646f63000111111111111111111111111111111111111111111111111111111111111111112222222222222222222222222222222222222222222222222222222222222222000000006361726400000000074444444444444444444444444444444444444444444444444444444444444444", + "tlv": "2200010040001900000000000000000000000000000000000000000000000000", + "enc": "01000102030405060708090a0b3c702ef28332f5795f7c14b3c02bfd0eb91d7fc665f20f875996825c999dc5f1cdc6fbe870bd416e63c03804b7b16e3b" + } +} diff --git a/forge-contracts/vectors/sealed_board__seal_card_empty.json b/forge-contracts/vectors/sealed_board__seal_card_empty.json new file mode 100644 index 000000000..b62e129c5 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__seal_card_empty.json @@ -0,0 +1,25 @@ +{ + "name": "seal_card_empty", + "description": "a card with nothing but its state (an archive or removal of an item never placed): only the padding record.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "seal", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "key": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", + "epoch": 0, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "nonce": "000102030405060708090a0b", + "doc": { + "type": "card", + "board": 7, + "item": "4444444444444444444444444444444444444444444444444444444444444444" + }, + "fields": {} + }, + "expected": { + "ad": "646173682d666f7267652f76322f646f63000111111111111111111111111111111111111111111111111111111111111111112222222222222222222222222222222222222222222222222222222222222222000000006361726400000000074444444444444444444444444444444444444444444444444444444444444444", + "tlv": "40001d0000000000000000000000000000000000000000000000000000000000", + "enc": "01000102030405060708090a0b5e7032f2c332ec795f7c14b3c02bfd0eb91d7fc665f20f875996825c999dc5f1eb65592e9a7b12b6a67c5d40a1fb72bd" + } +} diff --git a/forge-contracts/vectors/sealed_board__seal_card_fields_2048_bytes.json b/forge-contracts/vectors/sealed_board__seal_card_fields_2048_bytes.json new file mode 100644 index 000000000..5b9bf3b7a --- /dev/null +++ b/forge-contracts/vectors/sealed_board__seal_card_fields_2048_bytes.json @@ -0,0 +1,27 @@ +{ + "name": "seal_card_fields_2048_bytes", + "description": "field values at their 2048-byte cap.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "seal", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "key": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", + "epoch": 0, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "nonce": "000102030405060708090a0b", + "doc": { + "type": "card", + "board": 7, + "item": "4444444444444444444444444444444444444444444444444444444444444444" + }, + "fields": { + "f": "{\"5\":\"tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt\"}" + } + }, + "expected": { + "ad": "646173682d666f7267652f76322f646f63000111111111111111111111111111111111111111111111111111111111111111112222222222222222222222222222222222222222222222222222222222222222000000006361726400000000074444444444444444444444444444444444444444444444444444444444444444", + "tlv": "2408007b2235223a22747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474747474227d40001a0000000000000000000000000000000000000000000000000000", + "enc": "01000102030405060708090a0b3a782f89e107ce437d0860c7b45f897acd690bb211867bf32de2f628ede9b185651444ffa63557637a352e9e751eb567b2c8a6595cf2cf69ffbe742bafd5ac428d6d74ddaca13020d506de687cdd5d9efe612fb4592549f3bd02b03009412c49f896403cb15d1780b565f7d28c2ac81e02c046453868b6b03037652f6bd074fa5e63b027acd959aae798c03d9d4e25bc790be68a1e46636711e8b438d6bd64c023e547da26bed8f2621ef88755ec87fc7d1b103abae177a914b090194421eb4669544936f985d7a06b8897fa7dba1fc98e24d7fd8e8a98ae99bfdff58706d67a5eca7e09344e9da729ca96e47a7baa99e33ea975d806ef20ad34483d9b9629467b097567eef477b6a4c7acfdb19aabe1c1a56b832ad3854e6ba8f03a0384db5b27883353689d1bcfdee03f9c95752d710986d10c6f7c8f96f2026dc366c9501819d757de279b9823e9650a035917d02c070afccacfd6004f1b5880204d7845de96144800a3036c06c81812d75545638da94094aa0b4abf8cbb08edaf6b981210f13dccdc413041537ac4099b0868d41b7a2d2d45a71e20724e34300ddece6ef4f24d5da045536b8d137376914b118301020fde0bfc7413e6839ad873800313f81e58949604cdb8264f2f23a44cf2a64f431e40204868f8756cc586e858e3d46c2cde4d7c0ac6ba2aea87501bb28b214337504c1768f9e7832a006f2b0463396acd720146aadcb281702123ae7e3aea0ad3872086e45e8a9e72a5a5ca300b5cd21449b3ffa2c4ca68f067267b1cd900291229ae345ebfcec3cb299c62245ffe2b2bc0cb41cc9ddf7cfc8fd186a423e384853c7e1c44a2caa25584e90496e02d8471825a27e434650007d9d530b74ee1e7f5914dacc9601230c8abf302a0f5922751e920e96472b528c2741a35c49a786de6612737c26a7e85b23953d5120f7d79b0b3ebcb170ab86abfdd93f272e475a5e8fcc59fdda75015b8320b34303a025e573b07f107a08449153e97d66fcb2fcd51108a1db7f3601c2112c30c9328409ebbed22bedea721ea7d115188155541723e2f6b61fe746ad8f9bd705fb4cedd8514f08a142bfe5c27ca4e52de214304c84eaf3da1fdae3712329c10a4efe73d23a2c45de9a93635419b81b75b9df89b21a5b0718c0742c7e70687da73160229c65c33ce5b2b137bfc706634a0ad49b0a2f8926635cc24b4d1aa71b675ef967fc898ba6d36d9f2b7f066d4d90c274a6385e0212cf7267edecc7b13c5fa2985500b17aea59f1f541b556392f5ed6bf31681cd92a712a0bc7e0c01904b87b9492ed605b47f64e500c79e63ba7a9e29e54299e0814ce6a625ef940dbeecfff04652c785b7065b5cecae38e199dae91b01c17f6764988e2609ad862dd8665239806de1234bf4dd5a78a567e3c0e2af4e5580e514c8172208ee25d7004e122a911b341cfada2dff841609fc8de5a41d9f74c27208a7a887d21ee3ff9bb4256fe5b9a413b17ec751d9d96779620157e599a2e1b060440336ba3089e40312abb566106cfc7d74f9f1438b68a61d6ac72b4ed200450d50a2101534b1812e3ccf4bed5c496264a47ecbb41252d8c06c72bfa1e3bcc5fd22d7f894e27bb9013fefe5eaa3af7cc3919717385cb3cf1e18ad51a2d65b0be7721134d385a36b13251e32084a8f8204ca4b90e9c36203487c8de5a8075326a3f2f8581aa76d6d6c57d6474c8bb8f0ae9144e48834881ed7806d39dfc38f15f4552ceec4c104ec84860bce260d6bea16d915347f10560af560c6bd68e8c2b34cdaa535ee78b1b4bda8207fff0a74eb9488291c205602bbf20ac1979e172b167bc57b4d743361d09f48b53f5f1aeb01f4949b547148281ca97109f868d50f31bb1ddb11512ece3b9b7e88350c952b3ee9bce57ed0f460246a2137a5373e7d625387fe3b8613007325aa5fb00d98ecac828f2dac3bd287dd9822aabaac66ee3565ae59b29ec9a59a8cc34eb4cc76edcb77db496adfad66d26b28960cef0448d6948f579b20fa27d68ee9f5256ec0fb9ac6afbc7d99efd89fcfc36602ecf08b32a6a776b9cb690e41a48aadadf295d5ec7592d6cb584e9ec1c8b153c304217001be88483dde03630a6b63e9642785777609bcd9e53936fd7dc0a20bacd2c86f958755613d77612cbe759bce5a91b822ff29ea03162f20386a9836022eb416645606f56447ef96f4b83a350c7081854376fe2f844e971bb69460fafc736575fea8e6e2ba3a7b35b96065b4a7bdb2809e3986180973f351e2c12c3718c98eb8ea64d3ac245fe05e1293ca4581f1f6cd613047ed9904f6df22dbd7e02f2b60bbd922363869812583e5b9490143a9e8bf80a92c4e87a4ca09ef8dda323eeacae61e3d86cc9d668d2e339124f152f9dba95d69f159f70355a1f8d7fc21e45508c311306b3bb5771e24f38ded71ed2235d9ec394989e3c59d53618621b3db72df86610c62b5836084921e9f02218c00a198fcd6ab55b1acaa10c0986cf1daaad471a81888bf55dea4ccbbb1de265707aeb814dac2e69957f7827176742253d31ea6f6f3e8c4a4329ffe1e3efc89de30d925420a57b2ab1d43aab16a547aeabfc2d14c67e4b6b90080eccaa9bca0da5ba04bbc82f1142a1cb10bc4f3781e61cf6c984d5ddc19fa253c90f7aba1c2854672eb2ea11ec5c68ee58651f87bbb515b041dddd751d754e8f01ab476bc076778cea9c96b44cda879926c7e55d24d052b62d55671bc899b2423c135018a00074be8ba1dc662d4b498c6454ce4ace5db7a524d7622efcab668d50b8fd4c45da199cce62b2cacd3c24603d2d1b46bbffa6d8b874ea900a86a6fa1792f437d0079eae7dd5cad3358c68c963cd0960f235b702ace4f7e9d078ff4cba65c4e4a1004affb3fd802b65a1ef8cb0facf7ffca347a5bab1671be455b341355168edf8b368c6e048850a51e36d209392fdb82804f75f971798d" + } +} diff --git a/forge-contracts/vectors/sealed_board__seal_card_fields_2049_bytes.json b/forge-contracts/vectors/sealed_board__seal_card_fields_2049_bytes.json new file mode 100644 index 000000000..6e2c6237f --- /dev/null +++ b/forge-contracts/vectors/sealed_board__seal_card_fields_2049_bytes.json @@ -0,0 +1,25 @@ +{ + "name": "seal_card_fields_2049_bytes", + "description": "field values over 2048 bytes are refused.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "seal", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "key": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", + "epoch": 0, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "nonce": "000102030405060708090a0b", + "doc": { + "type": "card", + "board": 7, + "item": "4444444444444444444444444444444444444444444444444444444444444444" + }, + "fields": { + "f": "{\"5\":\"ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt\"}" + } + }, + "expected": { + "error": "malformed" + } +} diff --git a/forge-contracts/vectors/sealed_board__seal_card_rank_63.json b/forge-contracts/vectors/sealed_board__seal_card_rank_63.json new file mode 100644 index 000000000..537851da7 --- /dev/null +++ b/forge-contracts/vectors/sealed_board__seal_card_rank_63.json @@ -0,0 +1,27 @@ +{ + "name": "seal_card_rank_63", + "description": "a rank at its 63-digit cap.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "seal", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "key": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", + "epoch": 0, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "nonce": "000102030405060708090a0b", + "doc": { + "type": "card", + "board": 7, + "item": "4444444444444444444444444444444444444444444444444444444444444444" + }, + "fields": { + "rank": "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" + } + }, + "expected": { + "ad": "646173682d666f7267652f76322f646f63000111111111111111111111111111111111111111111111111111111111111111112222222222222222222222222222222222222222222222222222222222222222000000006361726400000000074444444444444444444444444444444444444444444444444444444444444444", + "tlv": "23003f7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a40001b000000000000000000000000000000000000000000000000000000", + "enc": "01000102030405060708090a0b3d701088b948960325066ec9ba518774c36705bc1f8875fd23ecf826e3e7bf8b6b1a4af1a83b596d743b20907b10bb69bcc6a85752fcc167f1b07a25a1dba24c836340a9c3d54454a172aa1c08a929ea8a155bc02d513d87c976c4447d35583db194bc09639cfbe7d4790a3efce80415" + } +} diff --git a/forge-contracts/vectors/sealed_board__seal_card_rank_64.json b/forge-contracts/vectors/sealed_board__seal_card_rank_64.json new file mode 100644 index 000000000..6b3c0ddfe --- /dev/null +++ b/forge-contracts/vectors/sealed_board__seal_card_rank_64.json @@ -0,0 +1,25 @@ +{ + "name": "seal_card_rank_64", + "description": "a rank over 63 digits is refused.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "seal", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "key": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", + "epoch": 0, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "nonce": "000102030405060708090a0b", + "doc": { + "type": "card", + "board": 7, + "item": "4444444444444444444444444444444444444444444444444444444444444444" + }, + "fields": { + "rank": "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" + } + }, + "expected": { + "error": "malformed" + } +} diff --git a/forge-contracts/vectors/sealed_board__seal_card_rank_trailing_zero.json b/forge-contracts/vectors/sealed_board__seal_card_rank_trailing_zero.json new file mode 100644 index 000000000..b59d6fa3f --- /dev/null +++ b/forge-contracts/vectors/sealed_board__seal_card_rank_trailing_zero.json @@ -0,0 +1,25 @@ +{ + "name": "seal_card_rank_trailing_zero", + "description": "an explicit rank never ends in 0.", + "case": "sealed_board", + "rules": "v2", + "input": { + "op": "seal", + "repoId": "1111111111111111111111111111111111111111111111111111111111111111", + "key": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", + "epoch": 0, + "ownerId": "2222222222222222222222222222222222222222222222222222222222222222", + "nonce": "000102030405060708090a0b", + "doc": { + "type": "card", + "board": 7, + "item": "4444444444444444444444444444444444444444444444444444444444444444" + }, + "fields": { + "rank": "V0" + } + }, + "expected": { + "error": "malformed" + } +} diff --git a/forge-web/app/repo/board/client.tsx b/forge-web/app/repo/board/client.tsx new file mode 100644 index 000000000..3277fdfa5 --- /dev/null +++ b/forge-web/app/repo/board/client.tsx @@ -0,0 +1,14 @@ +'use client' + +import { RepoScaffold } from '@/components/repo/repo-scaffold' +import { BoardPage } from '@/components/repo/boards/board-page' +import { useRepoAddress } from '@/hooks/use-query-param' + +export function BoardClient(): JSX.Element { + const addr = useRepoAddress() + return ( + + {(home) => } + + ) +} diff --git a/forge-web/app/repo/board/page.tsx b/forge-web/app/repo/board/page.tsx new file mode 100644 index 000000000..10d31634c --- /dev/null +++ b/forge-web/app/repo/board/page.tsx @@ -0,0 +1,11 @@ +import { QueryPage } from '@/components/route-loading' +import { BoardClient } from './client' + +/** `/repo/board?owner=&name=&b=` — one board: its views, filter, cards and item panel (`docs/design/boards.md` §4, §5). */ +export default function BoardRoute(): JSX.Element { + return ( + + + + ) +} diff --git a/forge-web/app/repo/board/settings/client.tsx b/forge-web/app/repo/board/settings/client.tsx new file mode 100644 index 000000000..b44ed510b --- /dev/null +++ b/forge-web/app/repo/board/settings/client.tsx @@ -0,0 +1,15 @@ +'use client' + +import { RepoScaffold } from '@/components/repo/repo-scaffold' +import { BoardSettings } from '@/components/repo/boards/board-settings' +import { useParam, useRepoAddress } from '@/hooks/use-query-param' + +export function BoardSettingsClient(): JSX.Element { + const addr = useRepoAddress() + const key = Number(useParam('b')) + return ( + + {(home) => } + + ) +} diff --git a/forge-web/app/repo/board/settings/page.tsx b/forge-web/app/repo/board/settings/page.tsx new file mode 100644 index 000000000..9f7a86147 --- /dev/null +++ b/forge-web/app/repo/board/settings/page.tsx @@ -0,0 +1,11 @@ +import { QueryPage } from '@/components/route-loading' +import { BoardSettingsClient } from './client' + +/** `/repo/board/settings?owner=&name=&b=` — a board's settings: columns, fields, sources, views, close and delete (`docs/design/boards.md`). */ +export default function BoardSettingsPage(): JSX.Element { + return ( + + + + ) +} diff --git a/forge-web/app/repo/boards/client.tsx b/forge-web/app/repo/boards/client.tsx new file mode 100644 index 000000000..0d7418944 --- /dev/null +++ b/forge-web/app/repo/boards/client.tsx @@ -0,0 +1,14 @@ +'use client' + +import { RepoScaffold } from '@/components/repo/repo-scaffold' +import { BoardsList } from '@/components/repo/boards/boards-list' +import { useRepoAddress } from '@/hooks/use-query-param' + +export function BoardsClient(): JSX.Element { + const addr = useRepoAddress() + return ( + + {(home) => } + + ) +} diff --git a/forge-web/app/repo/boards/page.tsx b/forge-web/app/repo/boards/page.tsx new file mode 100644 index 000000000..b8cba5f4f --- /dev/null +++ b/forge-web/app/repo/boards/page.tsx @@ -0,0 +1,11 @@ +import { QueryPage } from '@/components/route-loading' +import { BoardsClient } from './client' + +/** `/repo/boards?owner=&name=` — the repo's boards: open / closed, and New board for maintainers and writers (`docs/design/boards.md`). */ +export default function BoardsPage(): JSX.Element { + return ( + + + + ) +} diff --git a/forge-web/components/repo/boards/board-bits.tsx b/forge-web/components/repo/boards/board-bits.tsx new file mode 100644 index 000000000..7ff82757b --- /dev/null +++ b/forge-web/components/repo/boards/board-bits.tsx @@ -0,0 +1,66 @@ +'use client' + +/** + * Pieces the board layout's cards and the item panel share (`docs/design/boards.md` §4.1, §5.5), + * beside the ones every board surface shares (`board-fields.tsx`): an item's state in words, its + * reference on a board that spans repositories, and a custom field's value as a small chip on a card. + */ + +import type { BoardField, BoardItem, FieldValue } from '@/lib/rules/boards' +import { cn } from '@/lib/utils' + +import { ColorDot, fieldValueText } from './board-fields' + +/** What an item's state is called ("Open issue", "Merged pull request"). */ +export function itemStateWords(item: Pick): string { + if (item.kind === 'issue') return item.state === 'open' ? 'Open issue' : 'Closed issue' + switch (item.state) { + case 'merged': + return 'Merged pull request' + case 'closed': + return 'Closed pull request' + default: + return 'Open pull request' + } +} + +/** A custom field's value as a chip on a card: `Estimate 3`, `● P1`, `Iteration 4`. */ +export function FieldChip({ field, value }: { field: BoardField; value: FieldValue }): JSX.Element { + const text = fieldValueText(field, value) + const option = field.type === 'sel' ? field.options?.find((o) => o.id === value) : undefined + // A number or a date names its field ("Estimate 3"); an option, an iteration or text speaks for itself. + const shown = field.type === 'num' || field.type === 'date' ? `${field.name} ${text}` : text + return ( + + {option !== undefined ? : null} + {shown} + + ) +} + +/** + * The repository an item's label names, as a card shows it: the name after the owner + * (`owner/name`, where the owner is often a 44-character identity id, `board-page.tsx`). + */ +export function itemRepoName(item: Pick): string | undefined { + return item.repo?.slice(item.repo.lastIndexOf('/') + 1) +} + +/** + * An item's reference on a card, a table row or a roadmap line: `#12`, or `name #12` when the + * board spans repositories, with the full `owner/name#12` as its tooltip. The number never + * truncates; a long repository name does. + */ +export function ItemRef({ item, multiRepo, className }: { item: Pick; multiRepo: boolean; className?: string }): JSX.Element { + const name = multiRepo ? itemRepoName(item) : undefined + return ( + + {name !== undefined ? {name} : null} + #{item.number} + + ) +} diff --git a/forge-web/components/repo/boards/board-dialogs.tsx b/forge-web/components/repo/boards/board-dialogs.tsx new file mode 100644 index 000000000..8134509c0 --- /dev/null +++ b/forge-web/components/repo/boards/board-dialogs.tsx @@ -0,0 +1,68 @@ +'use client' + +/** + * The priced confirm a board action of several card writes passes through (`docs/design/boards.md` + * §2.6 re-rank, §5.4 the next iteration, archiving a column): one write per item, a create for + * each the signer has no card for, priced before signing (`priceBoardWrites`). It is the house + * {@link ConfirmDialog}: the balance and key budget are checked, one toast totals the writes, and + * a retry of one opening replays the same intents rather than signing twice. + */ + +import { ConfirmDialog } from '@/components/confirm-dialog' +import { useAuth } from '@/contexts/auth-context' +import type { BoardHookState } from '@/hooks/use-board' +import { crossRepoCardNeedsConfirm, type BulkWritten, type CardItem, type CardWriteOptions, type RepoRef } from '@/lib/repo' + +import { CROSS_REPO_CONFIRM, cardWritesCost } from './use-guarded-board' + +/** One bulk board action awaiting its confirm. */ +export interface BulkAction { + readonly title: string + readonly description: string + readonly confirmLabel: string + /** The items it writes (what is priced). */ + readonly items: readonly CardItem[] + /** Run it under the dialog's intent; a failed write is thrown, so the dialog shows it. */ + run(opts: CardWriteOptions): Promise + /** What the one toast says once every write landed. */ + readonly done: string +} + +export function BulkActionDialog({ action, state, home, onClose }: { action: BulkAction | null; state: BoardHookState; home: RepoRef; onClose: () => void }): JSX.Element | null { + const { identity } = useAuth() + if (action === null) return null + const crossRepo = action.items.some((i) => crossRepoCardNeedsConfirm(home, i.repoId)) + return ( + i.id), home.visibility === 'private')} + confirmLabel={action.confirmLabel} + successNote={action.done} + onConfirm={async (intent) => { + // This dialog is the confirm: another repo's items on a private board are confirmed by it. + const out = await action.run({ intent, ...(crossRepo ? { confirmCrossRepo: true } : {}) }) + if (out.failed !== null) throw out.failed.error + }} + /> + ) +} + +/** "1 card" / "3 cards". */ +export function cardCount(n: number): string { + return n === 1 ? '1 card' : `${n} cards` +} + +/** The re-rank action for a column's items in their order (§2.6). */ +export function rerankAction(state: BoardHookState, columnName: string, items: readonly CardItem[]): BulkAction { + return { + title: `Re-rank ${columnName}`, + description: `Spaces the order of ${cardCount(items.length)} evenly, so cards can be dropped between them again. The order stays as it is.`, + confirmLabel: `Re-rank ${cardCount(items.length)}`, + items, + run: (opts) => state.rerank(items, opts), + done: 'Column re-ranked', + } +} diff --git a/forge-web/components/repo/boards/board-fields.tsx b/forge-web/components/repo/boards/board-fields.tsx new file mode 100644 index 000000000..55fcb82b7 --- /dev/null +++ b/forge-web/components/repo/boards/board-fields.tsx @@ -0,0 +1,525 @@ +'use client' + +/** + * Pieces the board layouts, the board settings and the issue sidebar share (design + * `docs/design/boards.md` §2.2, §4, §5.6): board URLs, how a field value and a view key read, + * the editor of one field value and the Status select, an item's state icon, a colour dot. + */ + +import { useEffect, useRef, useState, type ReactNode } from 'react' +import { CheckCircle2, CircleDot } from 'lucide-react' +import { repoHref, type RepoAddress } from '@/hooks/use-query-param' +import { STATE_TEXT } from '@/lib/design/state' +import { DAY_MS, dateDays, fieldOfKey, fieldValueOk, iterationAt, iterationRange, type BoardField, type BoardItem, type BoardSpec, type FieldValue, type IterationRange } from '@/lib/rules/boards' +import { disabledField } from '@/components/ui/input' +import { pullStateView } from '@/components/repo/pull-state' +import { LabelChip } from '@/components/repo/issue-bits' +import { Author } from '@/components/author' +import { cn, shortId } from '@/lib/utils' + +// --------------------------------------------------------------------------------------------- +// URLs (§2.1: `/repo/board?owner=&name=&b=`) +// --------------------------------------------------------------------------------------------- + +/** A repository's boards list. */ +export function boardsHref(addr: RepoAddress, extra: Record = {}): string { + return repoHref('/repo/boards', addr, extra) +} + +/** Board `key` of `addr`. */ +export function boardHref(addr: RepoAddress, key: number, extra: Record = {}): string { + return repoHref('/repo/board', addr, { b: String(key), ...extra }) +} + +/** Board `key`'s settings. */ +export function boardSettingsHref(addr: RepoAddress, key: number): string { + return repoHref('/repo/board/settings', addr, { b: String(key) }) +} + +// --------------------------------------------------------------------------------------------- +// How values read +// --------------------------------------------------------------------------------------------- + +/** `YYYY-MM-DD` as "Oct 26, 2026" (UTC, as the board stores dates); `year: false` drops the year. */ +export function dayText(day: string, { year = true }: { readonly year?: boolean } = {}): string { + const d = dateDays(day) + if (d === null) return day + return new Date(d * DAY_MS).toLocaleDateString(undefined, { month: 'short', day: 'numeric', ...(year ? { year: 'numeric' } : {}), timeZone: 'UTC' }) +} + +/** "Oct 26 – Nov 8, 2026" (the start's year shown only when the two differ). */ +export function dayRangeText(start: string, end: string): string { + if (start === end) return dayText(start) + const sameYear = start.slice(0, 4) === end.slice(0, 4) + return `${dayText(start, { year: !sameYear })} – ${dayText(end)}` +} + +/** Iteration `k` of an `iter` field by name ("Iteration 3"). */ +export function iterationName(field: BoardField, k: number): string { + return iterationRange(field, k)?.name ?? `${field.name} ${k + 1}` +} + +/** A field value as text: an option's name, a number as stored, a date, an iteration's name; '' for none. */ +export function fieldValueText(field: BoardField, v: FieldValue | undefined): string { + if (v === undefined) return '' + switch (field.type) { + case 'sel': + return field.options?.find((o) => o.id === v)?.name ?? '' + case 'date': + return dayText(String(v)) + case 'iter': + return typeof v === 'number' ? iterationName(field, v) : '' + default: + return String(v) + } +} + +/** What each built-in view key is called (§2.7). */ +export const BUILTIN_KEY_LABEL: Readonly> = { + title: 'Title', + number: 'Number', + repo: 'Repository', + state: 'State', + author: 'Author', + assignees: 'Assignees', + assignee: 'Assignee', + labels: 'Labels', + label: 'Label', + milestone: 'Milestone', + created: 'Created', + status: 'Status', + rank: 'Board order', +} + +/** A view key's name: a built-in's, or a custom field's (`f`). */ +export function viewKeyLabel(spec: BoardSpec, key: string): string { + const k = key.startsWith('-') ? key.slice(1) : key + return BUILTIN_KEY_LABEL[k] ?? fieldOfKey(spec.fields, k)?.name ?? k +} + +/** A status column's name; "No status" for 0. */ +export function columnName(spec: BoardSpec, col: number): string { + return spec.columns.find((c) => c.id === col)?.name ?? 'No status' +} + +// --------------------------------------------------------------------------------------------- +// Small pictures +// --------------------------------------------------------------------------------------------- + +/** A column's or option's colour as a dot; a dashed ring where it has none. */ +export function ColorDot({ color, className }: { readonly color?: string | undefined; readonly className?: string }): JSX.Element { + return ( + + ) +} + +/** A colour dot and a label beside it, truncated (a column, an option). */ +export function DotLabel({ color, children, className }: { readonly color?: string | undefined; readonly children: ReactNode; readonly className?: string }): JSX.Element { + return ( + + + {children} + + ) +} + +/** An issue's or PR's state icon, as the lists draw it, with its name for screen readers. */ +/** + * A repository's `owner/name` label (`board-page.tsx`) as headings and cells show it: an owner + * that is an identity id shortened (`G1SAVd3…nC8ce/forge`), a DPNS name as it is. The full label + * stays the tooltip and what `repo:` matches. + */ +export function repoLabelText(label: string): string { + const cut = label.lastIndexOf('/') + if (cut < 0) return label + const owner = label.slice(0, cut) + return `${/^[1-9A-HJ-NP-Za-km-z]{43,44}$/.test(owner) ? shortId(owner) : owner}${label.slice(cut)}` +} + +export function ItemStateIcon({ item, className, decorative = false }: { readonly item: Pick; readonly className?: string; /** The state is said in words beside it: no screen-reader text of its own. */ readonly decorative?: boolean }): JSX.Element { + if (item.kind === 'pr') { + const v = pullStateView({ open: item.state === 'open', merged: item.state === 'merged' }) + return ( + <> + + {decorative ? null : {`${v.label} pull request`}} + + ) + } + const open = item.state === 'open' + const Icon = open ? CircleDot : CheckCircle2 + return ( + <> + + {decorative ? null : {open ? 'Open issue' : 'Closed issue'}} + + ) +} + +// --------------------------------------------------------------------------------------------- +// Editing one value +// --------------------------------------------------------------------------------------------- + +/** A compact select or input, as the lists' own selects. */ +export const controlClass = + 'rounded-md border border-anvil-300 bg-white px-2 py-1 text-dense text-anvil-900 dark:border-anvil-700 dark:bg-anvil-950 dark:text-anvil-100 coarse:min-h-11 ' + disabledField + +/** + * The iterations a picker offers: two before the current one to five after it (from the first + * when none has started), and `keep` (the item's own) wherever it is. + */ +export function iterationChoices(field: BoardField, now: number, keep?: number): IterationRange[] { + const cur = iterationAt(field, now) + const first = iterationRange(field, 0) + const at = cur ?? (first !== null && now < first.startMs ? 0 : null) + const ks = new Set() + if (at !== null) for (let k = Math.max(0, at - 2); k <= at + 5; k++) ks.add(k) + if (keep !== undefined) ks.add(keep) + return [...ks] + .sort((a, b) => a - b) + .map((k) => iterationRange(field, k)) + .filter((r): r is IterationRange => r !== null) +} + +/** What a typed value means for `field`: a value, null (cleared), or why it is refused. */ +export function parseFieldInput(field: BoardField, raw: string): { readonly value: FieldValue | null } | { readonly error: string } { + const t = raw.trim() + if (t === '') return { value: null } + let v: FieldValue + switch (field.type) { + case 'num': + v = Number(t) + if (!/^-?(\d+\.?\d*|\.\d+)$/.test(t)) return { error: 'Enter a number.' } + break + case 'sel': + case 'iter': + v = Number(t) + break + default: + v = t + } + if (fieldValueOk(field, v)) return { value: v === 0 ? 0 : v } + switch (field.type) { + case 'num': + return { error: 'Numbers go up to 10^15, and down to 0.000001 apart from 0.' } + case 'date': + return { error: 'Enter a date.' } + case 'text': + return { error: 'Text is at most 200 characters.' } + default: + return { error: `That isn't one of ${field.name}'s values.` } + } +} + +/** + * A select whose choice is written at once when made with the pointer, but when made with the + * keyboard (the arrows step through a closed select's options, which fires `change` on Windows + * and Linux) only on Enter or when the select is left: stepping past three options is one write, + * not three. Escape puts it back. + */ +function PickSelect({ + value, + onPick, + onCancel, + id, + label, + title, + autoFocus, + disabled, + className, + children, +}: { + readonly value: string + readonly onPick: (v: string) => void + readonly onCancel?: (() => void) | undefined + readonly id?: string | undefined + readonly label: string + readonly title?: string | undefined + readonly autoFocus: boolean + readonly disabled: boolean + readonly className?: string | undefined + readonly children: ReactNode +}): JSX.Element { + const [draft, setDraft] = useState(value) + useEffect(() => setDraft(value), [value]) + // the change came from the keyboard: wait for Enter or the blur + const keyed = useRef(false) + // this select was just settled (picked or put back): its blur writes nothing more + const settled = useRef(false) + const pick = (v: string): void => { + settled.current = true + keyed.current = false + if (v !== value) onPick(v) + else onCancel?.() + } + return ( + + ) +} + +/** + * The editor of one field value: a select for a single-select or iteration field (see + * {@link PickSelect}), an input for a number, date or text (written on Enter or when it loses + * focus; Escape puts it back, as does leaving it with a value it refuses). An empty value clears + * it. `onCommit` gets the new value only when it differs; `onCancel` is told when an edit ends + * without one. + */ +export function FieldInput({ + field, + value, + now, + onCommit, + onCancel, + id, + label, + autoFocus = false, + disabled = false, + className, +}: { + readonly field: BoardField + readonly value: FieldValue | undefined + readonly now: number + readonly onCommit: (value: FieldValue | null) => void + readonly onCancel?: () => void + readonly id?: string + /** The accessible name (the field's, by default). */ + readonly label?: string + readonly autoFocus?: boolean + readonly disabled?: boolean + readonly className?: string +}): JSX.Element { + const text = value === undefined ? '' : String(value) + const [draft, setDraft] = useState(text) + const [error, setError] = useState(null) + // Enter or Escape settled the edit: the blur that may follow writes nothing more + const settled = useRef(false) + useEffect(() => { + setDraft(text) + setError(null) + }, [text]) + const name = label ?? field.name + /** Write `raw` if it is a value and differs; false when it is refused. */ + const commit = (raw: string): boolean => { + const parsed = parseFieldInput(field, raw) + if ('error' in parsed) { + setError(parsed.error) + return false + } + setError(null) + if ((parsed.value ?? undefined) !== value) onCommit(parsed.value) + else onCancel?.() + return true + } + const putBack = (): void => { + setDraft(text) + setError(null) + onCancel?.() + } + if (field.type === 'sel' || field.type === 'iter') { + const choices = field.type === 'sel' ? (field.options ?? []).map((o) => ({ v: String(o.id), name: o.name })) : iterationChoices(field, now, typeof value === 'number' ? value : undefined).map((r) => ({ v: String(r.index), name: `${r.name} (${dayRangeText(r.start, r.end)})` })) + return ( + void commit(v)} onCancel={onCancel}> + + {choices.map((c) => ( + + ))} + + ) + } + return ( + + { + settled.current = false + setDraft(e.target.value) + }} + onFocus={() => { + settled.current = false + }} + onKeyDown={(e) => { + if (e.key === 'Enter') { + e.preventDefault() + e.stopPropagation() + // a refused value stays, with its reason, to be fixed + if (commit(draft)) settled.current = true + } else if (e.key === 'Escape') { + e.preventDefault() + e.stopPropagation() + settled.current = true + putBack() + } + }} + onBlur={() => { + if (settled.current) { + settled.current = false + return + } + // leaving with a refused value puts the old one back rather than strand the edit + if (!commit(draft)) putBack() + }} + className={cn(controlClass, 'w-full min-w-0', field.type === 'num' && 'font-mono tabular-nums', className)} + /> + {error !== null ? ( + + {error} + + ) : null} + + ) +} + +/** Why a closed item's Status offers no column before Done (§2.4 rule 1). */ +export const CLOSED_STAYS_DONE = 'Closed items show in Done, or in a column after it.' + +/** + * The Status select: every column, and "No status" while the item has none. For a closed or + * merged item (`closed`) the columns before Done are offered but disabled: the board shows it in + * Done whatever its card says (§2.4 rule 1), so such a move would change nothing. + */ +export function StatusSelect({ + spec, + value, + onChange, + onCancel, + closed = false, + id, + label = 'Status', + autoFocus = false, + disabled = false, + className, +}: { + readonly spec: BoardSpec + readonly value: number + readonly onChange: (col: number) => void + readonly onCancel?: () => void + /** The item is closed or merged. */ + readonly closed?: boolean + readonly id?: string + readonly label?: string + readonly autoFocus?: boolean + readonly disabled?: boolean + readonly className?: string +}): JSX.Element { + const doneAt = spec.done === 0 ? -1 : spec.columns.findIndex((c) => c.id === spec.done) + const held = closed && doneAt >= 0 + return ( + onChange(Number(v))} onCancel={onCancel}> + {value === 0 || !spec.columns.some((c) => c.id === value) ? ( + + ) : null} + {spec.columns.map((c, i) => ( + + ))} + + ) +} + +// --------------------------------------------------------------------------------------------- +// Groups (§4.1, §4.2) +// --------------------------------------------------------------------------------------------- + +/** + * A group's heading, for a view grouped by `by` (`groupRows`' keys): a column or option with its + * colour, an iteration with its dates, a person, a label, a milestone, a repository (named as + * `items` name it); "No " for the empty group. + */ +export function GroupHeading({ spec, by, groupKey, items }: { readonly spec: BoardSpec; readonly by: string; readonly groupKey: string | number | null; readonly items: readonly BoardItem[] }): JSX.Element { + const field = fieldOfKey(spec.fields, by) + if (by === 'status') { + const col = spec.columns.find((c) => c.id === groupKey) + return {col?.name ?? 'No status'} + } + if (groupKey === null) return {`No ${viewKeyLabel(spec, by).toLowerCase()}`} + if (field?.type === 'sel') { + const opt = field.options?.find((o) => o.id === groupKey) + return {opt?.name ?? String(groupKey)} + } + if (field?.type === 'iter' && typeof groupKey === 'number') { + const r = iterationRange(field, groupKey) + return ( + + {iterationName(field, groupKey)} + {r !== null ? {dayRangeText(r.start, r.end)} : null} + + ) + } + switch (by) { + case 'assignee': + return + case 'label': + return + case 'repo': { + const label = items.find((i) => i.repoId === groupKey)?.repo ?? String(groupKey) + return ( + + {repoLabelText(label)} + + ) + } + default: + return {String(groupKey)} + } +} diff --git a/forge-web/components/repo/boards/board-kanban.test.tsx b/forge-web/components/repo/boards/board-kanban.test.tsx new file mode 100644 index 000000000..eb2280fef --- /dev/null +++ b/forge-web/components/repo/boards/board-kanban.test.tsx @@ -0,0 +1,305 @@ +// @vitest-environment jsdom +/** + * The board layout (`docs/design/boards.md` §4.1, §5.2, §5.3): columns and cards from the fold, + * WIP limits, the keyboard move, quick add's three ways in, and the read-only board. + */ + +import { act } from 'react' +import { createRoot, type Root } from 'react-dom/client' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' + +import type { BoardHookState } from '@/hooks/use-board' +import type { RepoRef } from '@/lib/repo' +import { type Placement, foldBoard } from '@/lib/rules/boards' + +import { CARDS, HOME, ITEMS, ME, NOW, OTHER_REPO, SPEC, hookState, id } from './layout-fixture' +import type { BoardLayoutProps } from './layout-props' + +vi.mock('next/link', () => ({ default: ({ href, children, ...rest }: { href: string; children: React.ReactNode }) => {children} })) +vi.mock('@/hooks/use-sdk', () => ({ useSdk: () => ({ sdk: {}, ready: true, network: 'devnet', status: { phase: 'ready' } }) })) +vi.mock('@/hooks/use-dpns-name', () => ({ useDpnsName: () => undefined })) +vi.mock('@/contexts/auth-context', () => ({ useAuth: () => ({ signer: { identityId: ME }, identity: ME, balance: '100000000000', keyLimits: null }) })) +vi.mock('@/hooks/use-write-guard', () => ({ useWriteGuard: () => ({ check: () => true, failed: (e: unknown) => String(e), disabledReason: null }) })) +const resolveItemByNumber = vi.fn() +vi.mock('@/lib/repo', async (orig) => ({ ...(await orig()), resolveItemByNumber: (...a: unknown[]) => resolveItemByNumber(...a) })) +const resolveAnyRepoWith = vi.fn() +vi.mock('@/lib/repo/resolveRepo', async (orig) => ({ ...(await orig()), resolveAnyRepoWith: (...a: unknown[]) => resolveAnyRepoWith(...a) })) + +const { BoardKanban } = await import('./board-kanban') +const { quickAddPlan } = await import('./quick-add') + +;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true + +const FORGE = { core: 'C', collab: 'L', community: 'M', group: 'G' } as unknown as RepoRef['forge'] +const HOME_REF: RepoRef = { forge: FORGE, repoId: HOME, ownerId: ME, name: 'project', visibility: 'public' } +const OTHER_REF: RepoRef = { forge: FORGE, repoId: OTHER_REPO, ownerId: ME, name: 'tools', visibility: 'public' } + +const fold = foldBoard({ spec: SPEC, home: HOME, items: ITEMS, cards: CARDS, now: NOW }) +const placements = new Map(fold.items.map((p) => [p.id, p])) + +function props(over: Partial = {}, extra: Partial = {}): BoardLayoutProps { + const state = hookState({ fold, items: { items: ITEMS, hidden: new Set(), missing: new Set(), partial: false, hasOlderClosed: false, walks: new Map() }, ...over }) + const base = { state, spec: SPEC, view: { id: 1, name: 'Board', layout: 'board' as const, q: '' }, items: ITEMS, placements, onOpenItem: vi.fn(), home: HOME_REF, addr: { owner: 'alice', name: 'project' }, ...extra } + return { ...base, rows: extra.rows ?? base.items.flatMap((item) => (base.placements.has(item.id) ? [{ item, placement: base.placements.get(item.id) as Placement }] : [])) } +} + +let root: Root +let el: HTMLDivElement +beforeEach(() => { + window.matchMedia = ((query: string) => ({ matches: true, media: query, addEventListener: () => undefined, removeEventListener: () => undefined })) as unknown as typeof window.matchMedia + resolveItemByNumber.mockReset() + resolveAnyRepoWith.mockReset() + el = document.createElement('div') + document.body.append(el) + root = createRoot(el) +}) +afterEach(() => { + act(() => root.unmount()) + el.remove() +}) +const settle = () => act(async () => { await new Promise((r) => setTimeout(r, 0)) }) +const render = async (p: BoardLayoutProps): Promise => { + await act(async () => root.render()) + await settle() +} +const columns = () => [...el.querySelectorAll('[data-testid="kanban-column"]')] +const cardsIn = (col: HTMLElement) => [...col.querySelectorAll('[data-testid="kanban-card"]')].map((c) => Number(c.dataset['number'])) +const card = (n: number) => el.querySelector(`[data-testid="kanban-card"][data-number="${n}"]`) as HTMLElement +const key = (target: HTMLElement, k: string) => act(() => { target.dispatchEvent(new KeyboardEvent('keydown', { key: k, bubbles: true, cancelable: true })) }) +const type = (input: HTMLInputElement, value: string): void => { + Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')!.set!.call(input, value) + input.dispatchEvent(new Event('input', { bubbles: true })) +} + +describe('board layout', () => { + it('draws a column per status with the fold’s cards, counts and the closed item in Done', async () => { + await render(props()) + const cols = columns() + expect(cols.map((c) => c.getAttribute('aria-label'))).toEqual(['Todo', 'In progress', 'Done']) + expect(cols.map(cardsIn)).toEqual([[1, 5], [2, 3], [4]]) + expect(cols.map((c) => c.querySelector('[data-testid="column-count"]')?.textContent)).toEqual(['2', '2', '1']) + // The card says what it is: number, title, state, labels, its fields. + expect(card(1).getAttribute('aria-label')).toBe('project #1 Write the parser, Open issue, labels bug, Priority P0, Estimate 3, Iteration 1, Start Oct 26, 2026, Target Nov 6, 2026') + expect(card(1).textContent).toContain('Estimate 3') + // Two repositories on the board: cards carry their repository's name (the label in full as the tooltip). + expect(card(5).textContent).toContain('project#5') + expect(card(5).querySelector('[title="project#5"]')).not.toBeNull() + // The column sums the view's first number field. + expect(cols[1]?.querySelector('[data-testid="column-sum"]')?.textContent).toBe('Estimate 7') + }) + + it('shows a column over its WIP limit in red, with words for screen readers', async () => { + await render(props()) + const wip = columns()[1]?.querySelector('[data-testid="column-wip"]') as HTMLElement + expect(wip.dataset['over']).toBe('true') + expect(wip.textContent).toBe('2 / 1, over the limit') + expect(columns()[0]?.querySelector('[data-testid="column-wip"]')).toBeNull() + }) + + it('moves a card from the keyboard: Space picks it up, arrows move it, Space drops it', async () => { + const p = props() + await render(p) + const live = () => el.querySelector('[data-testid="kanban-live"]')?.textContent + card(1).focus() + await key(card(1), ' ') + expect(live()).toContain('Picked up #1 Write the parser. Todo, position 1 of 2.') + await key(card(1), 'ArrowRight') + expect(live()).toBe('In progress, position 1 of 3') + await key(card(1), 'ArrowDown') + expect(live()).toBe('In progress, position 2 of 3') + await key(card(1), ' ') + expect(live()).toBe('Dropped #1 Write the parser in In progress, position 2 of 3.') + // Between #2 and #3: just before #3 in the column's rank order. + expect(p.state.move).toHaveBeenCalledWith({ id: id('a'), repoId: HOME }, { col: 2 }, [ + { id: id('b'), rank: placements.get(id('b'))?.rank }, + { id: id('c'), rank: placements.get(id('c'))?.rank }, + ], id('c')) + }) + + it('keeps the focus on a card dropped in another column once the move renders there', async () => { + const p = props() + await render(p) + card(1).focus() + await key(card(1), ' ') + await key(card(1), 'ArrowRight') + await key(card(1), ' ') + // The hook's optimistic move renders after the drop: the card's element in Todo is gone. + const rows = p.rows.map((r) => (r.item.id === id('a') ? { ...r, placement: { ...r.placement, col: 2 } } : r)) + await render({ ...p, rows, placements: new Map(rows.map((r) => [r.item.id, r.placement])) }) + expect(cardsIn(columns()[1] as HTMLElement)).toContain(1) + expect(document.activeElement).toBe(card(1)) + }) + + it('shows a board spanning repositories by repo name, never an owner id that hides the number', async () => { + const owner = 'G1SAVd3dfdjNHJo2YmaNmhKThEa9kPVcwefCpeinC8ce' + const items = ITEMS.map((i) => ({ ...i, repo: `${owner}/${i.repoId === HOME ? 'project' : 'tools'}` })) + const p = props({}, { items }) + await render({ ...p, rows: p.rows.map((r) => ({ ...r, item: items.find((i) => i.id === r.item.id) ?? r.item })) }) + expect(card(5).textContent).toContain('tools#5') + expect(card(5).textContent).not.toContain(owner) + expect(card(5).querySelector(`[title="${owner}/tools#5"]`)).not.toBeNull() + expect(card(5).getAttribute('aria-label')).toMatch(/^tools #5 Secret/) + // Swimlanes by repository name the owner shortly (the full label is what repo: matches). + await render({ ...p, rows: p.rows.map((r) => ({ ...r, item: items.find((i) => i.id === r.item.id) ?? r.item })), view: { ...p.view, lane: 'repo' } }) + expect([...el.querySelectorAll('[data-testid="kanban-lane"]')].map((l) => l.getAttribute('aria-label'))).toEqual(['G1SAVd3…nC8ce/project', 'G1SAVd3…nC8ce/tools']) + const { repoLabelText } = await import('./board-fields') + expect(repoLabelText('alice/tools')).toBe('alice/tools') + }) + + it('cancels a keyboard move with Escape, writing nothing', async () => { + const p = props() + await render(p) + await key(card(2), ' ') + await key(card(2), 'ArrowLeft') + await key(card(2), 'Escape') + expect(el.querySelector('[data-testid="kanban-live"]')?.textContent).toBe('Move cancelled. #2 Ship the table is back in In progress, position 1 of 2.') + expect(p.state.move).not.toHaveBeenCalled() + }) + + it('warns when a drop takes a column over its WIP limit, and still moves', async () => { + const { useToasts } = await import('@/hooks/use-toasts') + const p = props() + await render(p) + await key(card(1), ' ') + await key(card(1), 'ArrowRight') + await key(card(1), 'Enter') + expect(p.state.move).toHaveBeenCalledTimes(1) + expect(useToasts.getState().toasts.some((t) => t.title === 'In progress is over its limit' && t.tone === 'warn')).toBe(true) + }) + + it('is read-only for a viewer who may not place cards: no grips, no quick add, Space opens', async () => { + const p = props({ can: { place: false, edit: false } }) + await render(p) + expect(el.querySelector('[data-testid="card-grip"]')).toBeNull() + expect(el.querySelector('[data-testid="quick-add-open"]')).toBeNull() + expect(el.querySelector('[aria-label$="column actions"]')).toBeNull() + await key(card(1), ' ') + expect(p.onOpenItem).toHaveBeenCalledWith(id('a')) + expect(p.state.move).not.toHaveBeenCalled() + }) +}) + +describe('swimlanes and phones', () => { + it('carries the copy of a card picked up in its second swimlane, from that swimlane', async () => { + // #2 has two labels: it shows in the "bug" and the "ui" swimlanes. + const items = ITEMS.map((i) => (i.number === 2 ? { ...i, labels: ['bug', 'ui'] } : i)) + const p = props({}, { items, view: { id: 1, name: 'Board', layout: 'board', q: '', lane: 'label' } }) + await render(p) + const copies = [...el.querySelectorAll('[data-testid="kanban-card"][data-number="2"]')] + expect(copies).toHaveLength(2) + const second = copies[1] as HTMLElement + second.focus() + await key(second, ' ') + expect(el.querySelector('[data-testid="kanban-live"]')?.textContent).toContain('In progress, swimlane ui, position 1 of 1.') + // Labels are the item's own: Up and Down stay in the swimlane, Left moves the column. + await key(second, 'ArrowUp') + await key(second, 'ArrowLeft') + expect(el.querySelector('[data-testid="kanban-live"]')?.textContent).toBe('Todo, swimlane ui, position 1 of 1') + await key(second, ' ') + expect(p.state.move).toHaveBeenCalledWith({ id: id('b'), repoId: HOME }, { col: 1 }, expect.any(Array), null) + }) + + it('shows one column at a time on a phone, and a keyboard carry keeps its card in view', async () => { + window.matchMedia = ((query: string) => ({ matches: false, media: query, addEventListener: () => undefined, removeEventListener: () => undefined })) as unknown as typeof window.matchMedia + const p = props() + await render(p) + expect(columns().map((c) => c.getAttribute('aria-label'))).toEqual(['Todo']) + const tabs = [...el.querySelectorAll('[data-testid="column-switcher"] [role="tab"]')] + expect(tabs.map((t) => t.getAttribute('aria-selected'))).toEqual(['true', 'false', 'false']) + card(1).focus() + await key(card(1), ' ') + await key(card(1), 'ArrowRight') + // Still the Todo column, the card still focused; the target column's tab is marked. + expect(document.activeElement).toBe(card(1)) + expect(tabs[1]?.className).toContain('ring-2') + await key(card(1), ' ') + expect(p.state.move).toHaveBeenCalledWith({ id: id('a'), repoId: HOME }, { col: 2 }, expect.any(Array), id('b')) + }) + + it('puts a carried card back when it loses focus', async () => { + const p = props() + await render(p) + card(1).focus() + await key(card(1), ' ') + await act(async () => card(1).blur()) + expect(el.querySelector('[data-testid="kanban-live"]')?.textContent).toContain('Move cancelled.') + await act(async () => card(2).click()) + expect(p.onOpenItem).toHaveBeenCalledWith(id('b')) + }) +}) + +describe('quick add', () => { + const openIn = async (col: number): Promise => { + const btn = columns()[col]?.querySelector('[data-testid="quick-add-open"]') as HTMLButtonElement + await act(async () => btn.click()) + return columns()[col]?.querySelector('[data-testid="quick-add"] input') as HTMLInputElement + } + const submit = async (input: HTMLInputElement, text: string): Promise => { + act(() => type(input, text)) + await act(async () => input.form?.requestSubmit()) + await settle() + } + + it('reads a title, #12, owner/name#12 and an item link', () => { + expect(quickAddPlan(' Fix the login ')).toEqual({ kind: 'title', title: 'Fix the login' }) + expect(quickAddPlan('#12')).toEqual({ kind: 'ref', number: 12 }) + expect(quickAddPlan('alice/tools#5')).toEqual({ kind: 'ref', owner: 'alice', name: 'tools', number: 5 }) + expect(quickAddPlan('https://forge.example/repo/issue/?owner=alice&name=tools&number=9')).toEqual({ kind: 'ref', owner: 'alice', name: 'tools', number: 9 }) + expect(quickAddPlan(' ')).toEqual({ kind: 'empty' }) + }) + + it('makes an issue from a title, at the bottom of the column', async () => { + const p = props({ quickAdd: vi.fn(async () => ({ item: { ...ITEMS[0], id: id('z'), number: 9 }, card: null, cardError: null }) as never) }) + await render(p) + await submit(await openIn(0), 'Write the docs') + expect(p.state.quickAdd).toHaveBeenCalledWith(expect.objectContaining({ title: 'Write the docs', col: 1, target: HOME_REF })) + const input = columns()[0]?.querySelector('[data-testid="quick-add"] input') as HTMLInputElement + expect(input.value).toBe('') + }) + + it('in a column of a field, sets the field in the new issue\'s one card (no second write)', async () => { + const p = props({ quickAdd: vi.fn(async () => ({ item: { ...ITEMS[0], id: id('z'), number: 9 }, card: null, cardError: null }) as never) }, { view: { id: 1, name: 'Board', layout: 'board', q: '', group: 'f1' } }) + await render(p) + // the first column is "No Priority" while it holds an item; the next is P0 (option 1) + const p0 = columns().findIndex((c) => c.getAttribute('aria-label')?.startsWith('P0')) + await submit(await openIn(p0), 'Write the docs') + expect(p.state.quickAdd).toHaveBeenCalledWith(expect.objectContaining({ title: 'Write the docs', col: SPEC.def, fields: { 1: 1 } })) + expect(p.state.write).not.toHaveBeenCalled() + }) + + it('adds an existing item by #number in this repo', async () => { + resolveItemByNumber.mockResolvedValue({ id: id('z'), kind: 'issue' }) + const p = props() + await render(p) + await submit(await openIn(1), '#12') + expect(resolveItemByNumber).toHaveBeenCalledWith({}, HOME_REF, 12) + expect(p.state.add).toHaveBeenCalledWith([{ id: id('z'), repoId: HOME }], 2, { confirmCrossRepo: true }) + }) + + it('adds another repo’s item by owner/name#number, and says when there is none', async () => { + resolveAnyRepoWith.mockResolvedValue({ repo: OTHER_REF }) + resolveItemByNumber.mockResolvedValueOnce({ id: id('y'), kind: 'pr' }).mockResolvedValueOnce(null) + const p = props() + await render(p) + const input = await openIn(0) + await submit(input, 'alice/tools#5') + expect(resolveAnyRepoWith).toHaveBeenCalledWith({}, FORGE, { owner: 'alice', name: 'tools' }) + expect(p.state.add).toHaveBeenCalledWith([{ id: id('y'), repoId: OTHER_REPO }], 1, { confirmCrossRepo: true }) + await submit(input, 'alice/tools#6') + expect(el.querySelector('[data-testid="quick-add-error"]')?.textContent).toBe('No issue or pull request #6 in alice/tools.') + }) + + it('asks first when a private repo’s board would name another repo’s item', async () => { + resolveAnyRepoWith.mockResolvedValue({ repo: OTHER_REF }) + resolveItemByNumber.mockResolvedValue({ id: id('y'), kind: 'issue' }) + const p = props({}, { home: { ...HOME_REF, visibility: 'private' } }) + await render(p) + await submit(await openIn(0), 'alice/tools#5') + expect(document.body.textContent).toContain('Place another repo’s item?') + expect(p.state.add).not.toHaveBeenCalled() + const ok = document.querySelector('[data-testid="confirm-action"]') as HTMLButtonElement + await act(async () => ok.click()) + await settle() + expect(p.state.add).toHaveBeenCalledTimes(1) + }) +}) diff --git a/forge-web/components/repo/boards/board-kanban.tsx b/forge-web/components/repo/boards/board-kanban.tsx new file mode 100644 index 000000000..08cdaeb6b --- /dev/null +++ b/forge-web/components/repo/boards/board-kanban.tsx @@ -0,0 +1,981 @@ +'use client' + +/** + * The board (kanban) layout (`docs/design/boards.md` §4.1, §5.2, §5.3): one column per status, or + * per value of the view's single-select or iteration field; optional swimlanes; cards with the + * item's repository (on a multi-repository board), number, title, state, labels, assignees and + * the view's fields. + * + * Members move cards by dragging (mouse or pen anywhere on a card; on touch screens by the grip, + * so a swipe elsewhere still scrolls the board) or from the keyboard: Space picks the focused + * card up, the arrow keys move it, Space or Enter drops it, Escape puts it back, and a live region + * says where it is. A move is one card write, shown at once and taken back with the reason when + * refused (the shell's banner). Between swimlanes a card moves only when they are a single-select + * or iteration field (the move sets it too); assignees, labels, milestones and repositories are + * the item's own, changed on the item. Dropping into a column over its WIP limit warns and still + * moves (§2.1). Readers, and everyone on a closed board, get the board without drag handles or + * quick add. + * + * On a phone one column shows at a time, with a switcher of every column (a card dragged onto a + * column's name moves there). + */ + +import { useEffect, useId, useMemo, useRef, useState, type KeyboardEvent as ReactKeyboardEvent, type PointerEvent as ReactPointerEvent } from 'react' +import { AlertTriangle, ChevronDown, ChevronRight, GripVertical, Loader2, Lock, MoreHorizontal } from 'lucide-react' + +import { AssigneeAvatars, LabelChip } from '@/components/repo/issue-bits' +import { useDismiss } from '@/components/repo/target-rail' +import { useMinWidth } from '@/hooks/use-prefs' +import { toast } from '@/hooks/use-toasts' +import { rankBefore, type CardItem, type CardPatch, type LabelDef, type MoveTarget } from '@/lib/repo' +import { + fieldById, + fieldKeyId, + iterationAt, + iterationRange, + sumFieldOf, + totals, + type BoardField, + type BoardFold, + type BoardItem, + type BoardSpec, + type FieldValue, + type Placement, +} from '@/lib/rules/boards' +import { cn, shortId } from '@/lib/utils' + +import { FieldChip, ItemRef, itemRepoName, itemStateWords } from './board-bits' +import { ColorDot, GroupHeading, ItemStateIcon, dayRangeText, fieldValueText, repoLabelText } from './board-fields' +import { BulkActionDialog, cardCount, rerankAction, type BulkAction } from './board-dialogs' +import type { BoardLayoutProps } from './layout-props' +import { QuickAdd, type QuickAddTarget } from './quick-add' +import { asksArchived, beforeOf, dropIndex, kanbanLayout, rankedColumn, type ColumnKey, type KanbanColumn, type KanbanLane } from './view-state' + +/** A place a card may be dropped: a column, a swimlane, a position among its other cards. */ +interface DropTarget { + readonly col: number + readonly lane: number + readonly index: number +} + +/** A cell of the board: a column of a swimlane. */ +interface CellPos { + readonly col: number + readonly lane: number +} + +/** A drag in progress. `invalid`: why the pointer's place takes no drop (another lane of a kind a move cannot set). */ +interface Drag { + readonly item: string + readonly from: DropTarget + readonly to: DropTarget + readonly mode: 'pointer' | 'keyboard' + readonly invalid: string | null +} + +/** How long after a keyboard drop the moved card is looked for in its new cell, to focus it. */ +const FOCUS_AFTER_MS = 3000 + +/** A column as shown: its name, colour, WIP limit and the key a move sets. */ +interface ColumnMeta { + readonly name: string + readonly color?: string | undefined + readonly wip: number | null + readonly hint?: string | undefined + readonly current?: boolean +} + +/** Pixels from the board's edge at which a drag scrolls it, and how far each frame. */ +const EDGE = 48 +const SCROLL_STEP = 14 +/** A mouse drag starts after the pointer moves this far (a click stays a click). */ +const DRAG_SLOP = 4 + +const LANE_NONE: Readonly> = { assignee: 'No assignee', label: 'No label', milestone: 'No milestone', repo: 'No repo' } +const LANE_WHY: Readonly> = { + assignee: 'Assignees are the item’s own. Change them in its panel.', + label: 'Labels are the item’s own. Change them in its panel.', + milestone: 'The milestone is the item’s own. Change it on the item.', + repo: 'A card stays in its repo.', +} + +function columnMeta(spec: BoardSpec, key: ColumnKey, now: number): ColumnMeta { + if (key.kind === 'status') { + const c = spec.columns.find((x) => x.id === key.col) + return c === undefined ? { name: 'No status', wip: null } : { name: c.name, color: c.color, wip: c.wip ?? null } + } + const field = fieldById(spec, key.field) + if (field === undefined) return { name: '?', wip: null } + if (key.value === null) return { name: `No ${field.name}`, wip: null } + if (field.type === 'sel') { + const o = field.options?.find((x) => x.id === key.value) + return { name: o?.name ?? '?', color: o?.color, wip: null } + } + const k = typeof key.value === 'number' ? key.value : null + const range = k === null ? null : iterationRange(field, k) + return { name: range?.name ?? String(key.value), wip: null, hint: range ? dayRangeText(range.start, range.end) : undefined, current: k !== null && iterationAt(field, now) === k } +} + +/** The items of the board's own status column `key` (any filter aside; archived ones too), in the fold's order. */ +function statusColumnItems(fold: BoardFold, key: Extract): readonly string[] { + return fold.columns.find((c) => c.id === key.col)?.items ?? [] +} + +/** Whether two drags are at the same place with the same verdict (a pointer move that changes neither needs no render). */ +function sameDrop(a: Drag, b: Drag): boolean { + return a.to.col === b.to.col && a.to.lane === b.to.lane && a.to.index === b.to.index && a.invalid === b.invalid +} + +/** The single-select or iteration field a lane key names (a move between its lanes sets it), else null. */ +function laneField(spec: BoardSpec, lane: string | null): number | null { + if (lane === null) return null + const id = fieldKeyId(lane) + return id !== null && fieldById(spec, id) !== undefined ? id : null +} + +/** Whether `e` comes from inside a control of the card (none today; kept for links added later). */ +function fromControl(e: { target: EventTarget | null; currentTarget: EventTarget }): boolean { + const t = e.target as HTMLElement | null + const c = t?.closest('a, button, input, select, textarea') + return c != null && c !== e.currentTarget +} + +export function BoardKanban(props: BoardLayoutProps): JSX.Element { + const { state, spec, view, items, rows, placements, onOpenItem, home, labels } = props + const fold = state.fold + const wide = useMinWidth(640) + const instructions = useId() + const rootRef = useRef(null) + const scrollRef = useRef(null) + const ghostRef = useRef(null) + const [drag, setDrag] = useState(null) + const dragRef = useRef(null) + dragRef.current = drag + const [announcement, setAnnouncement] = useState('') + const [collapsed, setCollapsed] = useState>(new Set()) + const [phoneCol, setPhoneCol] = useState(0) + const [bulk, setBulk] = useState(null) + const suppressClick = useRef(false) + /** + * A card to focus once it renders (after a keyboard drop it re-renders in its new column), until + * `until` (ms): the optimistic move may land a render or two after the drop. + */ + const focusAfter = useRef<(CellPos & { readonly id: string; readonly until?: number }) | null>(null) + + const canPlace = state.can.place + const archivedShown = asksArchived(view.q) + const sorted = view.sort !== undefined && view.sort !== 'rank' + const layout = useMemo(() => kanbanLayout(rows, spec, view, state.now), [rows, spec, view, state.now]) + const byId = useMemo(() => new Map(items.map((i) => [i.id, i])), [items]) + const hidden = state.items?.hidden + const multiRepo = new Set(items.map((i) => i.repoId)).size > 1 || spec.sources.some((s) => s.r !== undefined && s.r !== home?.repoId) + const sumField = sumFieldOf(spec, view) + const sumName = sumField === null ? null : (fieldById(spec, sumField)?.name ?? null) + const movableLane = laneField(spec, layout.lane) + + /** The cell's items as shown (a column of a lane). */ + const cell = (col: number, lane: number): readonly string[] => { + const c = layout.columns[col] + return c === undefined ? [] : (layout.lanes[lane]?.cells.get(c.id) ?? []) + } + + // --------------------------------------------------------------------------------------------- + // Moving + // --------------------------------------------------------------------------------------------- + + const cardItem = (id: string): CardItem => ({ id, repoId: byId.get(id)?.repoId ?? '' }) + + /** + * Where the card of `item` in cell `pos` is. An item with two assignees or labels shows in two + * swimlanes: each copy is its own place. + */ + const locate = (item: string, pos: CellPos): DropTarget | null => { + const index = cell(pos.col, pos.lane).indexOf(item) + return index < 0 ? null : { ...pos, index } + } + /** The card element of `item` in cell `pos` (item ids are base58: nothing to quote). */ + const cardEl = (item: string, pos: CellPos): HTMLElement | null => + rootRef.current?.querySelector(`[data-drop-cell][data-col="${pos.col}"][data-lane="${pos.lane}"] [data-card-id="${item}"]`) ?? null + + const sameSpot = (a: DropTarget, b: DropTarget): boolean => a.col === b.col && a.lane === b.lane && (sorted || a.index === b.index) + + /** Why a drop from lane `from` into lane `to` cannot be taken, or null. */ + const laneRefusal = (from: number, to: number): string | null => (from === to || movableLane !== null ? null : (LANE_WHY[layout.lane ?? ''] ?? 'Cards cannot move between these swimlanes.')) + + /** What a move into `col` writes: its status column, or its value of the grouping field. */ + const moveTargetOf = (col: KanbanColumn): MoveTarget => (col.key.kind === 'status' ? { col: col.key.col } : { field: col.key.field, value: col.key.value }) + + /** Sign the move of `item` to `to` (§5.2): one card write; the hook shows it at once and takes it back when refused. */ + const commit = (item: string, from: DropTarget, to: DropTarget): void => { + if (fold === null || sameSpot(from, to)) return + const column = layout.columns[to.col] + if (column === undefined) return + const ranked = rankedColumn(fold, column.key, archivedShown) + // A position in the shown cell: before the card under the gap (a sorted view: the bottom). + const before = sorted ? null : beforeOf(cell(to.col, to.lane), ranked, to.index, item) + const target = moveTargetOf(column) + const laneKey = layout.lanes[to.lane]?.key ?? null + const meta = columnMeta(spec, column.key, state.now) + // Into a column over its limit (§2.1): warned once the move is signed, and moved all the same. + const holds = column.key.kind === 'status' && from.col !== to.col ? statusColumnItems(fold, column.key).filter((id) => id !== item).length + 1 : 0 + const over = meta.wip !== null && holds > meta.wip + // A guard that stopped the write opened what fixes it; a refused write is taken back by the + // hook and its reason shows in the shell's banner. Nothing more to do here either way. + const done = (p: Promise): void => + void p.then( + () => (over ? toast({ title: `${meta.name} is over its limit`, tone: 'warn', detail: `It holds ${holds} items. Its limit is ${meta.wip}.` }) : undefined), + () => undefined, + ) + if (movableLane !== null && to.lane !== from.lane) { + // Another lane of a field: the column and the lane's value in one write. + const r = rankBefore(ranked, item, before) + if ('error' in r) { + // The same rank refused through the move: its banner offers the re-rank. + done(state.move(cardItem(item), target, ranked, before)) + return + } + const value = laneKey === null ? null : (laneKey as FieldValue) + const fields: Record = { [movableLane]: value } + if ('field' in target) fields[target.field] = target.value + const patch: CardPatch = { ...('col' in target ? { col: target.col } : {}), fields, rank: r.rank } + done(state.write(cardItem(item), patch)) + return + } + done(state.move(cardItem(item), target, ranked, before)) + } + + // --------------------------------------------------------------------------------------------- + // Keyboard (§5.2) + // --------------------------------------------------------------------------------------------- + + const titleOf = (id: string): string => { + const it = byId.get(id) + if (it === undefined || hidden?.has(id)) return 'A private item' + return `#${it.number} ${it.title}` + } + const where = (t: DropTarget, item: string): string => { + const column = layout.columns[t.col] + const name = column === undefined ? '' : columnMeta(spec, column.key, state.now).name + const n = cell(t.col, t.lane).filter((id) => id !== item).length + 1 + const lane = layout.lane === null ? '' : `, swimlane ${laneName(layout.lanes[t.lane]?.key ?? null)}` + return sorted ? `${name}${lane}` : `${name}${lane}, position ${Math.min(t.index, n - 1) + 1} of ${n}` + } + const laneName = (key: string | number | null): string => { + if (layout.lane === null) return '' + if (key === null) return LANE_NONE[layout.lane] ?? `No ${fieldById(spec, fieldKeyId(layout.lane) ?? 0)?.name ?? 'value'}` + if (layout.lane === 'assignee') return shortId(String(key)) + const f = fieldKeyId(layout.lane) + const field = f === null ? undefined : fieldById(spec, f) + if (field?.type === 'sel') return field.options?.find((o) => o.id === key)?.name ?? String(key) + if (field?.type === 'iter' && typeof key === 'number') return iterationRange(field, key)?.name ?? String(key) + if (layout.lane === 'repo') return repoLabelText(items.find((i) => i.repoId === key)?.repo ?? String(key)) + return String(key) + } + + const pickUp = (item: string, pos: CellPos): void => { + const from = locate(item, pos) + if (from === null) return + setDrag({ item, from, to: from, mode: 'keyboard', invalid: null }) + say(`Picked up ${titleOf(item)}. ${where(from, item)}. Use the arrow keys to move it, Space to drop it, Escape to cancel.`) + } + + const step = (d: Drag, key: string, carrying = true): DropTarget => { + const t = d.to + const lanes = layout.lanes.length + const len = (col: number, lane: number) => cell(col, lane).filter((id) => id !== d.item).length + const crossLanes = (movableLane !== null || !carrying) && lanes > 1 + // A sorted column has no positions to carry a card to; the focus still moves card by card. + const positional = !sorted || !carrying + switch (key) { + case 'ArrowLeft': + case 'ArrowRight': { + const col = Math.max(0, Math.min(layout.columns.length - 1, t.col + (key === 'ArrowLeft' ? -1 : 1))) + return { col, lane: t.lane, index: Math.min(t.index, len(col, t.lane)) } + } + case 'ArrowUp': + if (positional && t.index > 0) return { ...t, index: t.index - 1 } + return crossLanes && t.lane > 0 ? { col: t.col, lane: t.lane - 1, index: len(t.col, t.lane - 1) } : t + case 'ArrowDown': + if (positional && t.index < len(t.col, t.lane) - (carrying ? 0 : 1)) return { ...t, index: t.index + 1 } + return crossLanes && t.lane < lanes - 1 ? { col: t.col, lane: t.lane + 1, index: 0 } : t + default: + return t + } + } + + /** Say `text` in the live region, even when it says the same as last time (a move at an edge). */ + const say = (text: string): void => setAnnouncement((prev) => (prev === text ? `${text}\u00a0` : text)) + + const cancelCarry = (d: Drag): void => { + setDrag(null) + say(`Move cancelled. ${titleOf(d.item)} is back in ${where(d.from, d.item)}.`) + } + + const onCardKey = (e: ReactKeyboardEvent, id: string, pos: CellPos): void => { + if (e.nativeEvent.isComposing) return + const d = dragRef.current + // A mouse or touch drag owns the card until it ends (Escape cancels it). + if (d !== null && d.mode === 'pointer') return + if (d !== null && d.mode === 'keyboard' && d.item === id) { + if (e.key === ' ' || e.key === 'Enter') { + e.preventDefault() + setDrag(null) + if (sameSpot(d.from, d.to)) { + say(`${titleOf(id)} dropped where it was.`) + return + } + focusAfter.current = { id, col: d.to.col, lane: d.to.lane, until: Date.now() + FOCUS_AFTER_MS } + say(`Dropped ${titleOf(id)} in ${where(d.to, id)}.`) + commit(id, d.from, d.to) + } else if (e.key === 'Escape' || e.key === 'Tab') { + if (e.key === 'Escape') e.preventDefault() + cancelCarry(d) + } else if (e.key.startsWith('Arrow')) { + e.preventDefault() + // On a phone the card stays in view; the column switcher marks where it would go. + const to = step(d, e.key) + setDrag({ ...d, to }) + say(where(to, id)) + } + return + } + if (e.key === 'Enter') { + e.preventDefault() + onOpenItem(id) + } else if (e.key === ' ') { + e.preventDefault() + if (canPlace) pickUp(id, pos) + else onOpenItem(id) + } else if (e.key.startsWith('Arrow') && !e.altKey && !e.metaKey && !e.ctrlKey && !e.shiftKey) { + // Not carrying: the arrows move the focus between cards. + const at = locate(id, pos) + if (at === null) return + const next = step({ item: '', from: at, to: at, mode: 'keyboard', invalid: null }, e.key, false) + const ids = cell(next.col, next.lane) + const target = ids[Math.min(next.index, ids.length - 1)] + if (target === undefined || (target === id && next.col === pos.col && next.lane === pos.lane)) return + e.preventDefault() + if (!wide && next.col !== pos.col) { + // The column shows once the switch renders: focus it then. + focusAfter.current = { id: target, col: next.col, lane: next.lane } + setPhoneCol(next.col) + } else cardEl(target, next)?.focus() + } + } + + /** A keyboard carry ends when its card loses focus (a click elsewhere): it is put back. */ + const onCardBlur = (id: string): void => { + const d = dragRef.current + if (d !== null && d.mode === 'keyboard' && d.item === id) cancelCarry(d) + } + + // A card to focus once it has rendered (after a drop, or a phone's column switch). A drop's card + // is looked for on each render until it shows in its new cell (the move renders after the drop, + // and the card's old element, which held the focus, is gone by then), or until the deadline + // (a refused move puts it back where it was); anything else is tried once. + useEffect(() => { + const f = focusAfter.current + if (f === null) return + const el = cardEl(f.id, f) + if (el === null && f.until !== undefined && Date.now() < f.until) return + focusAfter.current = null + // not when the focus went somewhere else meanwhile (a dialog the move opened, a click away) + const at = document.activeElement + if (at === null || at === document.body || rootRef.current?.contains(at) === true) el?.focus() + }) + + // --------------------------------------------------------------------------------------------- + // Pointer and touch + // --------------------------------------------------------------------------------------------- + + /** The drop target under the pointer, from the cells' and cards' boxes. */ + const hitTest = (x: number, y: number, d: Drag): Drag => { + const el = document.elementFromPoint(x, y) + const tab = el?.closest('[data-drop-tab]') + if (tab != null && rootRef.current?.contains(tab)) { + const col = Number(tab.dataset['dropTab']) + return { ...d, to: { col, lane: d.from.lane, index: cell(col, d.from.lane).filter((id) => id !== d.item).length }, invalid: null } + } + const zone = el?.closest('[data-drop-cell]') + if (zone == null || !rootRef.current?.contains(zone)) return d + const col = Number(zone.dataset['col']) + const lane = Number(zone.dataset['lane']) + const mids = [...zone.querySelectorAll('[data-card-id]')] + .filter((c) => c.dataset['cardId'] !== d.item) + .map((c) => { + const r = c.getBoundingClientRect() + return r.top + r.height / 2 + }) + return { ...d, to: { col, lane, index: dropIndex(mids, y) }, invalid: laneRefusal(d.from.lane, lane) } + } + + // A drag outlives the render it started in (a poll, a move taken back): its listeners read the board through this. + const live = useRef({ hitTest, commit }) + live.current = { hitTest, commit } + + /** Hold back the click that ends a drag (or a cancelled one) until the pointer is up. */ + const swallowClick = (): void => { + suppressClick.current = true + window.addEventListener('pointerup', () => setTimeout(() => (suppressClick.current = false), 0), { once: true }) + } + + const startPointer = (e: ReactPointerEvent, id: string, handle: boolean, pos: CellPos): void => { + if (!canPlace || e.button !== 0 || dragRef.current !== null || fromControl(e)) return + // Touch scrolls the board unless the gesture starts on the grip. + if (e.pointerType === 'touch' && !handle) return + const from = locate(id, pos) + if (from === null) return + const source = e.currentTarget.closest('[data-card-id]') ?? e.currentTarget + const box = source.getBoundingClientRect() + const start = { x: e.clientX, y: e.clientY } + const offset = { x: e.clientX - box.left, y: e.clientY - box.top } + let started = handle && e.pointerType === 'touch' + let pointer = { x: e.clientX, y: e.clientY } + let frame: number | null = null + if (handle) e.preventDefault() + + const place = (): void => { + const g = ghostRef.current + if (g !== null) { + g.style.width = `${box.width}px` + g.style.transform = `translate(${pointer.x - offset.x}px, ${pointer.y - offset.y}px)` + g.style.visibility = 'visible' + } + } + const begin = (): void => { + started = true + const d: Drag = { item: id, from, to: from, mode: 'pointer', invalid: null } + setDrag(d) + dragRef.current = d + requestAnimationFrame(place) + frame = requestAnimationFrame(tick) + } + // Auto-scroll near the board's and the window's edges while dragging. + const tick = (): void => { + const d = dragRef.current + if (d === null || d.mode !== 'pointer') return + const s = scrollRef.current + let moved = false + if (s !== null) { + const r = s.getBoundingClientRect() + if (pointer.x < r.left + EDGE && s.scrollLeft > 0) { + s.scrollLeft -= SCROLL_STEP + moved = true + } else if (pointer.x > r.right - EDGE && s.scrollLeft + s.clientWidth < s.scrollWidth) { + s.scrollLeft += SCROLL_STEP + moved = true + } + } + if (pointer.y < EDGE) { + window.scrollBy(0, -SCROLL_STEP) + moved = true + } else if (pointer.y > window.innerHeight - EDGE) { + window.scrollBy(0, SCROLL_STEP) + moved = true + } + if (moved) { + const next = live.current.hitTest(pointer.x, pointer.y, d) + if (!sameDrop(next, d)) setDrag(next) + } + frame = requestAnimationFrame(tick) + } + const move = (ev: PointerEvent): void => { + if (ev.pointerId !== e.pointerId) return + pointer = { x: ev.clientX, y: ev.clientY } + if (!started) { + if (Math.hypot(ev.clientX - start.x, ev.clientY - start.y) < DRAG_SLOP) return + begin() + } + ev.preventDefault() + place() + const d = dragRef.current + if (d === null) return + const next = live.current.hitTest(ev.clientX, ev.clientY, d) + if (!sameDrop(next, d)) { + dragRef.current = next + setDrag(next) + } + } + const end = (ev: PointerEvent): void => { + if (ev.pointerId !== e.pointerId) return + cleanup() + const d = dragRef.current + if (!started || d === null) return + // The click that follows a drag is not an open. + suppressClick.current = true + setTimeout(() => (suppressClick.current = false), 0) + setDrag(null) + dragRef.current = null + if (ev.type === 'pointerup' && d.invalid === null) live.current.commit(id, d.from, d.to) + else if (d.invalid !== null) say(d.invalid) + } + const cancelKey = (ev: KeyboardEvent): void => { + if (ev.key !== 'Escape') return + ev.preventDefault() + cleanup() + if (started) swallowClick() + setDrag(null) + dragRef.current = null + } + const cleanup = (): void => { + if (frame !== null) cancelAnimationFrame(frame) + window.removeEventListener('pointermove', move) + window.removeEventListener('pointerup', end) + window.removeEventListener('pointercancel', end) + window.removeEventListener('keydown', cancelKey) + } + window.addEventListener('pointermove', move, { passive: false }) + window.addEventListener('pointerup', end) + window.addEventListener('pointercancel', end) + window.addEventListener('keydown', cancelKey) + if (started) begin() + } + // --------------------------------------------------------------------------------------------- + // Rendering + // --------------------------------------------------------------------------------------------- + + if (fold === null) return
+ + const columnTotalsOf = (col: KanbanColumn): { count: number; sum: number | null } => + totals( + col.items.map((id) => ({ item: byId.get(id) as BoardItem, placement: placements.get(id) as Placement })), + sumField, + ) + /** The whole column's count (any filter aside), for its WIP limit. */ + const wipCount = (col: KanbanColumn): number => (col.key.kind === 'status' ? statusColumnItems(fold, col.key).length : col.items.length) + + const quickTarget = (col: KanbanColumn, lane: KanbanLane, name: string): QuickAddTarget => { + const fields: Record = {} + if (col.key.kind === 'field') fields[col.key.field] = col.key.value + if (movableLane !== null && lane.key !== null) fields[movableLane] = lane.key as FieldValue + return { col: col.key.kind === 'status' ? col.key.col : null, fields, column: col.key.kind === 'status' ? rankedColumn(fold, col.key) : [], name } + } + /** Quick add goes where a new item lands: every cell, but with lanes of the item's own facts only the "No …" lane. */ + const quickAddIn = (lane: KanbanLane): boolean => home !== undefined && canPlace && (layout.lane === null || movableLane !== null || lane.key === null) + + const openMenu = (col: KanbanColumn, action: 'rerank' | 'archive'): void => { + const meta = columnMeta(spec, col.key, state.now) + if (action === 'rerank') { + setBulk(rerankAction(state, meta.name, rankedColumn(fold, col.key, archivedShown).map((c) => cardItem(c.id)))) + return + } + const ids = col.items.filter((id) => placements.get(id)?.archived === null) + setBulk({ + title: `Archive ${meta.name}`, + description: `Archives the ${cardCount(ids.length)} this view shows in ${meta.name}. They stay on the board under Only archived.`, + confirmLabel: `Archive ${cardCount(ids.length)}`, + items: ids.map(cardItem), + run: (opts) => state.archive(ids.map(cardItem), opts), + done: 'Cards archived', + }) + } + + const renderCard = (id: string, pos: CellPos): JSX.Element => { + const item = byId.get(id) + const placement = placements.get(id) + if (item === undefined || placement === undefined) return
+ const isHidden = hidden?.has(id) === true + const pending = state.pending.has(id) + const carried = drag?.item === id && drag.from.col === pos.col && drag.from.lane === pos.lane + return ( +