diff --git a/apps/mobile/src/tokens.test.ts b/apps/mobile/src/tokens.test.ts
new file mode 100644
index 0000000..e5e23ec
--- /dev/null
+++ b/apps/mobile/src/tokens.test.ts
@@ -0,0 +1,73 @@
+///
+// Hermit's design tokens (docs/design/polish/decisions.md): every color is a docs/brand/tokens.json value, or a mix of
+// two of them (mix): the surfaces between the canvas and white, the tonal fills between a surface and an accent, and
+// the scrims. Light is Quiet craft; dark is Deep sea. The motion tokens live beside them (docs/design/polish/decisions.md,
+// "Motion"): plain numbers, no animation library.
+import { test } from "node:test";
+import assert from "node:assert/strict";
+import { mix } from "./theme.ts";
+import { duration, easing, stagger, staggerDelay } from "./motion.ts";
+
+test("mix(a, b, t) holds at a when t is 0 and at b when t is 1", () => {
+ assert.equal(mix("#F5EDE1", "#B4483A", 0), "#F5EDE1");
+ assert.equal(mix("#F5EDE1", "#B4483A", 1), "#B4483A");
+});
+
+test("mix rounds to a whole hex channel at the midpoint", () => {
+ // Half of #000000 → #808080: the blend rounds, it does not truncate.
+ assert.equal(mix("#000000", "#FFFFFF", 0.5), "#808080");
+});
+
+test("mix answers in uppercase #RRGGBB even when the inputs are lowercase", () => {
+ assert.match(mix("#ffffff", "#2b221b", 0.5), /^#[0-9A-F]{6}$/);
+});
+
+test("mix keeps every channel between the two inputs while t is between 0 and 1", () => {
+ const pairs: Array<[string, string]> = [
+ ["#000000", "#FFFFFF"],
+ ["#06121D", "#5EF0CF"],
+ ["#2B221B", "#8A5912"],
+ ];
+ for (const [a, b] of pairs) {
+ for (const t of [0.25, 0.5, 0.75]) {
+ const c = mix(a, b, t);
+ const blend = [0, 1, 2].map((i) => parseInt(c.slice(1 + i * 2, 3 + i * 2), 16));
+ const from = [0, 1, 2].map((i) => parseInt(a.slice(1 + i * 2, 3 + i * 2), 16));
+ const to = [0, 1, 2].map((i) => parseInt(b.slice(1 + i * 2, 3 + i * 2), 16));
+ for (let i = 0; i < 3; i++) {
+ assert.ok(
+ blend[i] >= Math.min(from[i], to[i]) && blend[i] <= Math.max(from[i], to[i]),
+ `channel ${i} of ${c} should stay between ${a} and ${b} at t=${t}`,
+ );
+ }
+ }
+ }
+});
+
+test("staggerDelay spaces items out by one step and stops at stagger.max", () => {
+ assert.equal(staggerDelay(0), 0);
+ assert.equal(staggerDelay(1), stagger.step);
+ assert.equal(staggerDelay(2), stagger.step * 2);
+ assert.equal(staggerDelay(stagger.max - 1), (stagger.max - 1) * stagger.step);
+ assert.equal(staggerDelay(stagger.max), stagger.max * stagger.step);
+ assert.equal(staggerDelay(stagger.max + 4), stagger.max * stagger.step);
+});
+
+test("duration tokens are positive whole milliseconds, a press is instant and sheet is the longest", () => {
+ const values = Object.values(duration);
+ for (const v of values) {
+ assert.ok(Number.isInteger(v), `duration ${v} should be a whole number of milliseconds`);
+ assert.ok(v > 0, `duration ${v} should be positive`);
+ }
+ assert.ok(duration.press < 100, `a press should read as instant, got ${duration.press}`);
+ assert.equal(duration.sheet, Math.max(...values), `sheet should be the longest duration, got ${duration.sheet}`);
+});
+
+test("easing curves are four numbers whose control-x values sit between 0 and 1", () => {
+ for (const curve of Object.values(easing)) {
+ assert.equal(curve.length, 4, `a cubic-bezier needs four numbers, got ${curve.length}`);
+ for (const x of [curve[0], curve[2]]) {
+ assert.ok(x >= 0 && x <= 1, `a cubic-bezier x value should sit between 0 and 1, got ${x}`);
+ }
+ }
+});
diff --git a/packages/core/test/a2a-store.test.ts b/packages/core/test/a2a-store.test.ts
index ca84579..918c160 100644
--- a/packages/core/test/a2a-store.test.ts
+++ b/packages/core/test/a2a-store.test.ts
@@ -1,6 +1,6 @@
import { beforeEach, describe, expect, test } from "vitest";
import { nodeSql } from "@hermit/sql-node";
-import { createA2aStore, TASK_STATES, type A2aStore, type TaskState } from "../src/a2a-store.ts";
+import { canTransition, createA2aStore, OPEN_TASK_STATES, TASK_STATES, TERMINAL_TASK_STATES, type A2aStore, type TaskState } from "../src/a2a-store.ts";
import { migrate } from "../src/schema.ts";
import type { SqlPort } from "../src/ports.ts";
@@ -313,3 +313,64 @@ describe("a2a store (A2A 1.0, migration 18)", () => {
expect(rejected.status.reason).toBe("hop_cap");
});
});
+
+describe("A2A task states", () => {
+ test("the open and terminal lists hold every state exactly once and share none", () => {
+ const all = [...OPEN_TASK_STATES, ...TERMINAL_TASK_STATES];
+ expect(new Set(all).size).toBe(all.length);
+ expect([...all].sort()).toEqual([...TASK_STATES].sort());
+ for (const state of OPEN_TASK_STATES) {
+ expect(TERMINAL_TASK_STATES).not.toContain(state);
+ }
+ });
+
+ test("a terminal state cannot move anywhere", () => {
+ for (const terminal of TERMINAL_TASK_STATES) {
+ for (const next of TASK_STATES) {
+ expect(canTransition(terminal, next), `${terminal} to ${next}`).toBe(false);
+ }
+ }
+ });
+
+ test("no state moves to itself", () => {
+ for (const state of TASK_STATES) {
+ expect(canTransition(state, state), state).toBe(false);
+ }
+ });
+
+ test("nothing moves back to submitted", () => {
+ for (const state of TASK_STATES) {
+ expect(canTransition(state, "TASK_STATE_SUBMITTED"), state).toBe(false);
+ }
+ });
+
+ test("every open state can reach a terminal state", () => {
+ const reachesTerminal = (start: TaskState): boolean => {
+ const seen = new Set([start]);
+ const queue: TaskState[] = [start];
+ while (queue.length > 0) {
+ const current = queue.shift()!;
+ if (TERMINAL_TASK_STATES.includes(current)) return true;
+ for (const next of TASK_STATES) {
+ if (canTransition(current, next) && !seen.has(next)) {
+ seen.add(next);
+ queue.push(next);
+ }
+ }
+ }
+ return false;
+ };
+ for (const state of OPEN_TASK_STATES) {
+ expect(reachesTerminal(state), state).toBe(true);
+ }
+ });
+
+ test("the A2A 1.0 spot checks hold", () => {
+ expect(canTransition("TASK_STATE_SUBMITTED", "TASK_STATE_WORKING")).toBe(true);
+ expect(canTransition("TASK_STATE_WORKING", "TASK_STATE_INPUT_REQUIRED")).toBe(true);
+ expect(canTransition("TASK_STATE_INPUT_REQUIRED", "TASK_STATE_WORKING")).toBe(true);
+ expect(canTransition("TASK_STATE_AUTH_REQUIRED", "TASK_STATE_CANCELED")).toBe(true);
+ expect(canTransition("TASK_STATE_SUBMITTED", "TASK_STATE_COMPLETED")).toBe(false);
+ expect(canTransition("TASK_STATE_INPUT_REQUIRED", "TASK_STATE_COMPLETED")).toBe(false);
+ });
+});