Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

fix(core): accept O2-family refusal codes [O2,O3]

Corey Olson681dc003033f
diff --git a/src/machine.js b/src/machine.js
index 6efe9e8d..c227112b 100644
--- a/src/machine.js
+++ b/src/machine.js
@@ -305,7 +305,7 @@ function unnamedRefusals(machine) {
const used = new Set([...machine.moves.flatMap((move) => move.guards), ...Object.values(machine.exitGuards).flat()]);
const problems = [];
for (const guard of machine.guards) {
- if (guard.id !== IN_STATE && !/^[A-Z][A-Z_]*$/.test(guard.refuse)) problems.push(`guard ${guard.id} names no refusal code`);
+ if (guard.id !== IN_STATE && !/^[A-Z][A-Z0-9_]*$/.test(guard.refuse)) problems.push(`guard ${guard.id} names no refusal code`);
if (!guard.rule.trim()) problems.push(`guard ${guard.id} states no rule`);
if (!guard.next.trim()) problems.push(`guard ${guard.id} refuses without a next step`);
if (!used.has(guard.id)) problems.push(`guard ${guard.id} is declared but no move uses it`);
@@ -313,9 +313,9 @@ function unnamedRefusals(machine) {
for (const move of machine.moves.filter((entry) => !entry.by.includes('clock'))) {
const checks = move.guards.filter((id) => id === IN_STATE).length;
if (checks !== 1) problems.push(`${move.verb} checks the item's state ${checks} times, not once`);
- if (!/^[A-Z][A-Z_]*$/.test(move.refuse ?? '')) problems.push(`${move.verb} names no code for an item in the wrong state`);
+ if (!/^[A-Z][A-Z0-9_]*$/.test(move.refuse ?? '')) problems.push(`${move.verb} names no code for an item in the wrong state`);
}
- if (!/^[A-Z][A-Z_]*$/.test(machine.unknownMove.refuse) || !machine.unknownMove.next.trim()) problems.push('the unknown-move refusal has no code or no next step');
+ if (!/^[A-Z][A-Z0-9_]*$/.test(machine.unknownMove.refuse) || !machine.unknownMove.next.trim()) problems.push('the unknown-move refusal has no code or no next step');
return problems;
}
diff --git a/test/machine.test.js b/test/machine.test.js
index bea431d4..0d1ec9da 100644
--- a/test/machine.test.js
+++ b/test/machine.test.js
@@ -115,7 +115,7 @@ function codeWalk(read) {
const [file, name] = key.split('#');
const { bodies, named, spaces } = load(file);
const body = bodies.get(name) ?? '';
- const codes = new Set([...body.matchAll(/new Refused\(\s*(['"])([A-Z_]+)\1/g)].map((match) => match[2]));
+ const codes = new Set([...body.matchAll(/new Refused\(\s*(['"])([A-Z0-9_]+)\1/g)].map((match) => match[2]));
const callees = [
...[...body.matchAll(/(?<!\w)(?<!(?<!\.\.)\.)(\w+)\(/g)].map(([, callee]) => (bodies.has(callee) ? `${file}#${callee}` : named.get(callee) ?? CALLBACKS[file]?.[callee])),
...[...body.matchAll(/\b(\w+)\.(\w+)\(/g)].map(([, space, callee]) => (spaces.has(space) ? `${spaces.get(space)}#${callee}` : undefined)),