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(docs): diagram guarded non-final states [I10, M1]

Corey Olsone2d223ae9708
diff --git a/docs/img/draw.mjs b/docs/img/draw.mjs
index 3a635d84..2e0f1b34 100644
--- a/docs/img/draw.mjs
+++ b/docs/img/draw.mjs
@@ -180,7 +180,7 @@ const ROUTES = {
'submitted>withdrawn': { points: [[525, 208], [525, 280]] },
};
-/** Where the guards every move into a final state passes are listed, by state id. */
+/** Where the guards every move into a guarded state passes are listed, by state id. */
const GUARD_NOTES = {
verified: { x: 640, y: 26, w: 176, leader: [[735, 122], [735, 146]] },
withdrawn: { x: 640, y: 284, w: 176, leader: [[640, 313], [609, 313]] },
@@ -201,7 +201,7 @@ function wrapped(words, count) {
/**
* An item's life, drawn from the lifecycle declaration: every state, every move's verb between
* each pair of states, the moves that keep a state, the final states, and the refusals every move
- * into a final state can raise.
+ * into a guarded state can raise.
*
* @param {any} [machine]
* @returns {string}
@@ -223,6 +223,7 @@ export function drawLifecycle(machine = MACHINE) {
}
}
const finals = machine.states.filter((state) => state.final).map((state) => state.id);
+ const guardedStates = machine.states.filter((state) => (machine.exitGuards[state.id] ?? []).length > 0).map((state) => state.id);
const body = [text(24, 34, "An item's life", 'head'), text(140, 34, `starts ${machine.initial}; ends ${finals.join(' or ')}`, 'aside')];
for (const state of machine.states) {
const [x, y] = PLACES[state.id];
@@ -238,7 +239,7 @@ export function drawLifecycle(machine = MACHINE) {
const [x, y, anchor] = route.label;
wrapped(said, route.wrap ?? 1).forEach((line, i) => body.push(text(x, y + i * 15, line, `label${route.back ? ' back' : ''}`, anchor)));
}
- for (const id of finals) {
+ for (const id of guardedStates) {
const note = GUARD_NOTES[id];
if (!note) throw new Error(`no place for the guards into ${id}: add it to GUARD_NOTES in docs/img/draw.mjs`);
const codes = machine.exitGuards[id].map((guard) => machine.guards.find((each) => each.id === guard).refuse);
diff --git a/test/readme.test.js b/test/readme.test.js
index f9bae085..49a58fdc 100644
--- a/test/readme.test.js
+++ b/test/readme.test.js
@@ -198,6 +198,23 @@ test('the lifecycle figure is drawn from the declaration, and refuses a state or
assert.match(texts(drawLifecycle(bench)).map((text) => text.words).join(' '), /\bbench\b/, 'a new move between drawn states is named without touching draw.mjs');
});
+test('the lifecycle figure keeps the guards into a state that is not final [I10, M1]', () => {
+ const fixture = {
+ ...MACHINE,
+ states: MACHINE.states.map((state) => state.id === 'verified' ? { ...state, final: false } : state),
+ moves: [...MACHINE.moves, { verb: 'reopen', from: ['verified'], to: 'open', by: ['coordinator'], guards: [] }],
+ };
+ const svg = drawLifecycle(fixture);
+ const shown = texts(svg).map((text) => text.words).join(' \n ');
+ assert.ok(shown.includes('every way into verified'), 'the non-final guarded state has its entry note');
+ for (const guard of MACHINE.exitGuards.verified) {
+ assert.ok(shown.includes(MACHINE.guards.find((each) => each.id === guard).refuse), `the non-final verified note includes refusal ${guard}`);
+ }
+ assert.match(shown, /\breopen\b/, 'the verified-to-open move remains visible');
+ assert.ok(shown.includes('starts open; ends withdrawn'), 'the caption names only the declared final state');
+ assert.equal(svg.includes('data-final="verified"'), false, 'verified is not marked final in the fixture');
+});
+
test('README pins its approved Philosophy, Key concepts and Why structure [I10,I12]', () => {
const philosophy = README.indexOf('## Philosophy');
const concepts = README.indexOf('### Key concepts', philosophy);