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(demo): wait for populated board before capture [I13,A10]

Corey Olson8d5110e74478
diff --git a/docs/demo/api/v1/boards.json b/docs/demo/api/v1/boards.json
new file mode 100644
index 00000000..d7da4e5f
--- /dev/null
+++ b/docs/demo/api/v1/boards.json
@@ -0,0 +1 @@
+{"version":1,"boards":[{"root":"demo-board","name":"Demo board","project":"Pullboard demo","added":"2026-10-06T12:00:00.000Z","id":"demo-board"}],"warnings":[]}
diff --git a/docs/demo/api/v1/boards/demo-board/events.json b/docs/demo/api/v1/boards/demo-board/events.json
new file mode 100644
index 00000000..aaacba58
--- /dev/null
+++ b/docs/demo/api/v1/boards/demo-board/events.json
@@ -0,0 +1 @@
+{"version":1,"events":[{"event_id":1,"event_at":"2026-10-06T12:00:00.000Z","event_by":"coordinator","event_kind":"join","item_id":null,"event_detail":"{\"lane\":\"coordinator\"}"},{"event_id":2,"event_at":"2026-10-06T12:00:00.000Z","event_by":"coordinator","event_kind":"add","item_id":1,"event_detail":"{\"lane\":\"app\",\"specIds\":[\"G1\"],\"after\":[],\"route\":\"strong\"}"},{"event_id":3,"event_at":"2026-10-06T12:00:00.000Z","event_by":"coordinator","event_kind":"add","item_id":2,"event_detail":"{\"lane\":\"app\",\"specIds\":[\"G1\"],\"after\":[],\"route\":\"strong\"}"},{"event_id":4,"event_at":"2026-10-06T12:00:00.000Z","event_by":"coordinator","event_kind":"add","item_id":3,"event_detail":"{\"lane\":\"app\",\"specIds\":[\"G1\"],\"after\":[],\"route\":\"strong\"}"},{"event_id":5,"event_at":"2026-10-06T12:00:00.000Z","event_by":"coordinator","event_kind":"add","item_id":4,"event_detail":"{\"lane\":\"app\",\"specIds\":[\"G1\"],\"after\":[],\"route\":\"strong\"}"},{"event_id":6,"event_at":"2026-10-06T12:00:00.000Z","event_by":"coordinator","event_kind":"add","item_id":5,"event_detail":"{\"lane\":\"app\",\"specIds\":[\"G1\"],\"after\":[],\"route\":\"strong\"}"},{"event_id":7,"event_at":"2026-10-06T12:00:00.000Z","event_by":"coordinator","event_kind":"add","item_id":6,"event_detail":"{\"lane\":\"app\",\"specIds\":[\"G1\"],\"after\":[],\"route\":\"strong\"}"},{"event_id":8,"event_at":"2026-10-06T12:00:00.000Z","event_by":"coordinator","event_kind":"withdraw","item_id":6,"event_detail":"{\"reason\":\"this example was dropped\"}"},{"event_id":9,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-1","event_kind":"join","item_id":null,"event_detail":"{\"lane\":\"app\"}"},{"event_id":10,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-1","event_kind":"family","item_id":null,"event_detail":"{\"family\":\"codex\"}"},{"event_id":11,"event_at":"2026-10-06T12:00:00.000Z","event_by":"review-1","event_kind":"join","item_id":null,"event_detail":"{\"lane\":\"review\"}"},{"event_id":12,"event_at":"2026-10-06T12:00:00.000Z","event_by":"review-1","event_kind":"family","item_id":null,"event_detail":"{\"family\":\"claude\"}"},{"event_id":13,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-1","event_kind":"claim","item_id":1,"event_detail":"{\"leaseUntil\":\"2026-10-06T14:00:00.000Z\",\"digest\":\"52a5178db8543870702679e144835094724f1864a9f63dd507f110de09884926\"}"},{"event_id":14,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-1","event_kind":"submit","item_id":1,"event_detail":"{\"commit\":\"a74d5c50fc8238e781ca272d5431877d41d94aaa\",\"tree\":\"529da464ab862967df96a3dbb968986e02be9c09\",\"policyCommit\":\"2828af4e4d41e981899dd1e7c818f4689ddb513a\"}"},{"event_id":15,"event_at":"2026-10-06T12:00:00.000Z","event_by":"review-1","event_kind":"reject","item_id":1,"event_detail":"{\"reason\":\"BEHAVIOR_MISMATCH\",\"commit\":\"a74d5c50fc8238e781ca272d5431877d41d94aaa\"}"},{"event_id":16,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-1","event_kind":"claim","item_id":1,"event_detail":"{\"leaseUntil\":\"2026-10-06T14:00:00.000Z\",\"digest\":\"52a5178db8543870702679e144835094724f1864a9f63dd507f110de09884926\"}"},{"event_id":17,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-1","event_kind":"submit","item_id":1,"event_detail":"{\"commit\":\"74f59a4c65af520a7220f503bf0aeb8f31af8aa8\",\"tree\":\"a4151ea69dda49bf35349795630361ee271d5670\",\"policyCommit\":\"2828af4e4d41e981899dd1e7c818f4689ddb513a\"}"},{"event_id":18,"event_at":"2026-10-06T12:00:00.000Z","event_by":"review-1","event_kind":"accept","item_id":1,"event_detail":"{\"reason\":\"CRITERION_MET\",\"commit\":\"74f59a4c65af520a7220f503bf0aeb8f31af8aa8\"}"},{"event_id":19,"event_at":"2026-10-06T12:00:00.000Z","event_by":"coordinator","event_kind":"merged","item_id":1,"event_detail":"{\"commit\":\"74f59a4c65af520a7220f503bf0aeb8f31af8aa8\"}"},{"event_id":20,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-2","event_kind":"join","item_id":null,"event_detail":"{\"lane\":\"app\"}"},{"event_id":21,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-2","event_kind":"family","item_id":null,"event_detail":"{\"family\":\"codex\"}"},{"event_id":22,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-2","event_kind":"claim","item_id":3,"event_detail":"{\"leaseUntil\":\"2026-10-06T14:00:00.000Z\",\"digest\":\"8ec224349992913da728bb07a6d30da2d899364954e80d4fa187aa8dc9b442e0\"}"},{"event_id":23,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-2","event_kind":"submit","item_id":3,"event_detail":"{\"commit\":\"d0108498c7a127f264184dc00d77ef67271a38ad\",\"tree\":\"8dcdda1969040b065338d3bb3aab24c851fa7ddf\",\"policyCommit\":\"74f59a4c65af520a7220f503bf0aeb8f31af8aa8\"}"},{"event_id":24,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-3","event_kind":"join","item_id":null,"event_detail":"{\"lane\":\"app\"}"},{"event_id":25,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-3","event_kind":"family","item_id":null,"event_detail":"{\"family\":\"codex\"}"},{"event_id":26,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-3","event_kind":"claim","item_id":4,"event_detail":"{\"leaseUntil\":\"2026-10-06T14:00:00.000Z\",\"digest\":\"a61ed95a765eefbf7fdb8797154d99adeaf28b752bdd66bfb8926623e270fb38\"}"},{"event_id":27,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-3","event_kind":"shout","item_id":null,"event_detail":"{\"shout\":1,\"to\":\"coordinator\",\"decision\":true,\"request\":false,\"answers\":null}"},{"event_id":28,"event_at":"2026-10-06T12:00:00.000Z","event_by":"coordinator","event_kind":"pass","item_id":null,"event_detail":"{\"shout\":2,\"to\":\"person\",\"decision\":true,\"request\":false,\"answers\":1}"},{"event_id":29,"event_at":"2026-10-06T12:00:00.000Z","event_by":"person","event_kind":"answer","item_id":null,"event_detail":"{\"shout\":3,\"to\":\"coordinator\",\"decision\":false,\"request\":false,\"answers\":2,\"channel\":\"terminal\"}"},{"event_id":30,"event_at":"2026-10-06T12:00:00.000Z","event_by":"person","event_kind":"answer","item_id":null,"event_detail":"{\"shout\":4,\"to\":\"app-3\",\"decision\":false,\"request\":false,\"answers\":1,\"channel\":\"terminal\"}"},{"event_id":31,"event_at":"2026-10-06T12:00:00.000Z","event_by":"coordinator","event_kind":"hold","item_id":null,"event_detail":"{\"lane\":\"review\",\"reason\":\"Waiting for the next demo item.\"}"}],"eventLogVersion":1}
diff --git a/docs/demo/api/v1/boards/demo-board/state.json b/docs/demo/api/v1/boards/demo-board/state.json
new file mode 100644
index 00000000..90f2c086
--- /dev/null
+++ b/docs/demo/api/v1/boards/demo-board/state.json
@@ -0,0 +1 @@
+{"version":1,"state":{"root":"demo-board","lanes":["coordinator","app","review"],"owning":["app"],"items":[{"id":6,"title":"Withdrawn example","lane":"app","status":"withdrawn","route":"strong","owner":null,"reviewer":null,"reviewUntil":null,"builtBy":null,"verifiedBy":null,"specs":["G1"],"criterion":"The demo includes withdrawn work.","brief":"","commit":null,"merged":null,"blockedBy":[],"updatedAt":"2026-10-06T12:00:00.000Z","verdict":null,"verdicts":[],"history":[{"kind":"add","by":"coordinator","at":"2026-10-06T12:00:00.000Z"},{"kind":"withdraw","by":"coordinator","at":"2026-10-06T12:00:00.000Z"}],"thread":[{"type":"move","eventId":7,"kind":"add","by":"coordinator","at":"2026-10-06T12:00:00.000Z","detail":{"lane":"app","specIds":["G1"],"after":[],"route":"strong"}},{"type":"move","eventId":8,"kind":"withdraw","by":"coordinator","at":"2026-10-06T12:00:00.000Z","detail":{"reason":"this example was dropped"}}]},{"id":5,"title":"Decision follow-up","lane":"app","status":"open","route":"strong","owner":null,"reviewer":null,"reviewUntil":null,"builtBy":null,"verifiedBy":null,"specs":["G1"],"criterion":"The board keeps a follow-up visible after the person answers.","brief":"","commit":null,"merged":null,"blockedBy":[],"updatedAt":"2026-10-06T12:00:00.000Z","verdict":null,"verdicts":[],"history":[{"kind":"add","by":"coordinator","at":"2026-10-06T12:00:00.000Z"}],"thread":[{"type":"move","eventId":6,"kind":"add","by":"coordinator","at":"2026-10-06T12:00:00.000Z","detail":{"lane":"app","specIds":["G1"],"after":[],"route":"strong"}}]},{"id":4,"title":"Claimed for work","lane":"app","status":"claimed","route":"strong","owner":"app-3","reviewer":null,"reviewUntil":null,"builtBy":null,"verifiedBy":null,"specs":["G1"],"criterion":"The demo item is being worked on.","brief":"","commit":null,"merged":null,"blockedBy":[],"updatedAt":"2026-10-06T12:00:00.000Z","verdict":null,"verdicts":[],"history":[{"kind":"add","by":"coordinator","at":"2026-10-06T12:00:00.000Z"},{"kind":"claim","by":"app-3","at":"2026-10-06T12:00:00.000Z"}],"thread":[{"type":"move","eventId":5,"kind":"add","by":"coordinator","at":"2026-10-06T12:00:00.000Z","detail":{"lane":"app","specIds":["G1"],"after":[],"route":"strong"}},{"type":"move","eventId":26,"kind":"claim","by":"app-3","at":"2026-10-06T12:00:00.000Z","detail":{"leaseUntil":"2026-10-06T14:00:00.000Z","digest":"a61ed95a765eefbf7fdb8797154d99adeaf28b752bdd66bfb8926623e270fb38"}}]},{"id":3,"title":"Ready for review","lane":"app","status":"submitted","route":"strong","owner":"app-2","reviewer":null,"reviewUntil":null,"builtBy":"app-2","verifiedBy":null,"specs":["G1"],"criterion":"The demo item is submitted for review.","brief":"","commit":"d0108498c7a127f264184dc00d77ef67271a38ad","merged":null,"blockedBy":[],"updatedAt":"2026-10-06T12:00:00.000Z","verdict":null,"verdicts":[],"history":[{"kind":"add","by":"coordinator","at":"2026-10-06T12:00:00.000Z"},{"kind":"claim","by":"app-2","at":"2026-10-06T12:00:00.000Z"},{"kind":"submit","by":"app-2","at":"2026-10-06T12:00:00.000Z"}],"thread":[{"type":"move","eventId":4,"kind":"add","by":"coordinator","at":"2026-10-06T12:00:00.000Z","detail":{"lane":"app","specIds":["G1"],"after":[],"route":"strong"}},{"type":"move","eventId":22,"kind":"claim","by":"app-2","at":"2026-10-06T12:00:00.000Z","detail":{"leaseUntil":"2026-10-06T14:00:00.000Z","digest":"8ec224349992913da728bb07a6d30da2d899364954e80d4fa187aa8dc9b442e0"}},{"type":"move","eventId":23,"kind":"submit","by":"app-2","at":"2026-10-06T12:00:00.000Z","detail":{"commit":"d0108498c7a127f264184dc00d77ef67271a38ad","tree":"8dcdda1969040b065338d3bb3aab24c851fa7ddf","policyCommit":"74f59a4c65af520a7220f503bf0aeb8f31af8aa8"}}]},{"id":2,"title":"Future work","lane":"app","status":"open","route":"strong","owner":null,"reviewer":null,"reviewUntil":null,"builtBy":null,"verifiedBy":null,"specs":["G1"],"criterion":"The board keeps another item open for later work.","brief":"","commit":null,"merged":null,"blockedBy":[],"updatedAt":"2026-10-06T12:00:00.000Z","verdict":null,"verdicts":[],"history":[{"kind":"add","by":"coordinator","at":"2026-10-06T12:00:00.000Z"}],"thread":[{"type":"move","eventId":3,"kind":"add","by":"coordinator","at":"2026-10-06T12:00:00.000Z","detail":{"lane":"app","specIds":["G1"],"after":[],"route":"strong"}}]},{"id":1,"title":"Reviewed and accepted","lane":"app","status":"verified","route":"strong","owner":"app-1","reviewer":null,"reviewUntil":null,"builtBy":"app-1","verifiedBy":"review-1","specs":["G1"],"criterion":"The demo item is accepted after review.","brief":"","commit":"74f59a4c65af520a7220f503bf0aeb8f31af8aa8","merged":"74f59a4c65af520a7220f503bf0aeb8f31af8aa8","blockedBy":[],"updatedAt":"2026-10-06T12:00:00.000Z","verdict":{"decision":"ACCEPT","reason":"CRITERION_MET","note":"Tried the edge that failed before; the revised demo passes.","by":"review-1","at":"2026-10-06T12:00:00.000Z","commit":"74f59a4c65af520a7220f503bf0aeb8f31af8aa8"},"verdicts":[{"decision":"REJECT","reason":"BEHAVIOR_MISMATCH","note":"The example skipped an edge; revise it before merging.","by":"review-1","at":"2026-10-06T12:00:00.000Z","commit":"a74d5c50fc8238e781ca272d5431877d41d94aaa"},{"decision":"ACCEPT","reason":"CRITERION_MET","note":"Tried the edge that failed before; the revised demo passes.","by":"review-1","at":"2026-10-06T12:00:00.000Z","commit":"74f59a4c65af520a7220f503bf0aeb8f31af8aa8"}],"history":[{"kind":"add","by":"coordinator","at":"2026-10-06T12:00:00.000Z"},{"kind":"claim","by":"app-1","at":"2026-10-06T12:00:00.000Z"},{"kind":"submit","by":"app-1","at":"2026-10-06T12:00:00.000Z"},{"kind":"reject","by":"review-1","at":"2026-10-06T12:00:00.000Z"},{"kind":"claim","by":"app-1","at":"2026-10-06T12:00:00.000Z"},{"kind":"submit","by":"app-1","at":"2026-10-06T12:00:00.000Z"},{"kind":"accept","by":"review-1","at":"2026-10-06T12:00:00.000Z"},{"kind":"merged","by":"coordinator","at":"2026-10-06T12:00:00.000Z"}],"thread":[{"type":"move","eventId":2,"kind":"add","by":"coordinator","at":"2026-10-06T12:00:00.000Z","detail":{"lane":"app","specIds":["G1"],"after":[],"route":"strong"}},{"type":"move","eventId":13,"kind":"claim","by":"app-1","at":"2026-10-06T12:00:00.000Z","detail":{"leaseUntil":"2026-10-06T14:00:00.000Z","digest":"52a5178db8543870702679e144835094724f1864a9f63dd507f110de09884926"}},{"type":"move","eventId":14,"kind":"submit","by":"app-1","at":"2026-10-06T12:00:00.000Z","detail":{"commit":"a74d5c50fc8238e781ca272d5431877d41d94aaa","tree":"529da464ab862967df96a3dbb968986e02be9c09","policyCommit":"2828af4e4d41e981899dd1e7c818f4689ddb513a"}},{"type":"move","eventId":15,"kind":"reject","by":"review-1","at":"2026-10-06T12:00:00.000Z","detail":{"reason":"BEHAVIOR_MISMATCH","commit":"a74d5c50fc8238e781ca272d5431877d41d94aaa"}},{"type":"move","eventId":16,"kind":"claim","by":"app-1","at":"2026-10-06T12:00:00.000Z","detail":{"leaseUntil":"2026-10-06T14:00:00.000Z","digest":"52a5178db8543870702679e144835094724f1864a9f63dd507f110de09884926"}},{"type":"move","eventId":17,"kind":"submit","by":"app-1","at":"2026-10-06T12:00:00.000Z","detail":{"commit":"74f59a4c65af520a7220f503bf0aeb8f31af8aa8","tree":"a4151ea69dda49bf35349795630361ee271d5670","policyCommit":"2828af4e4d41e981899dd1e7c818f4689ddb513a"}},{"type":"move","eventId":18,"kind":"accept","by":"review-1","at":"2026-10-06T12:00:00.000Z","detail":{"reason":"CRITERION_MET","commit":"74f59a4c65af520a7220f503bf0aeb8f31af8aa8"}},{"type":"move","eventId":19,"kind":"merged","by":"coordinator","at":"2026-10-06T12:00:00.000Z","detail":{"commit":"74f59a4c65af520a7220f503bf0aeb8f31af8aa8"}}]}],"shouts":[{"shout_id":4,"shout_from":"person","shout_to":"app-3","shout_text":"Person answered #2: Proceed with the verified change.","shout_at":"2026-10-06T12:00:00.000Z","shout_decision":0,"shout_answers":1,"shout_evidence_kind":null,"shout_evidence_outcome":null,"shout_evidence_item":null,"shout_evidence_commit":null,"shout_request":0,"shout_request_outcome":""},{"shout_id":3,"shout_from":"person","shout_to":"coordinator","shout_text":"Proceed with the verified change.","shout_at":"2026-10-06T12:00:00.000Z","shout_decision":0,"shout_answers":2,"shout_evidence_kind":null,"shout_evidence_outcome":null,"shout_evidence_item":null,"shout_evidence_commit":null,"shout_request":0,"shout_request_outcome":""},{"shout_id":2,"shout_from":"coordinator","shout_to":"person","shout_text":"Passed up from app-3: The review is complete. May the verified change proceed?\nCoordinator note: The review passed; ask the person before proceeding.","shout_at":"2026-10-06T12:00:00.000Z","shout_decision":1,"shout_answers":1,"shout_evidence_kind":null,"shout_evidence_outcome":null,"shout_evidence_item":null,"shout_evidence_commit":null,"shout_request":0,"shout_request_outcome":""},{"shout_id":1,"shout_from":"app-3","shout_to":"coordinator","shout_text":"The review is complete. May the verified change proceed?","shout_at":"2026-10-06T12:00:00.000Z","shout_decision":1,"shout_answers":null,"shout_evidence_kind":null,"shout_evidence_outcome":null,"shout_evidence_item":null,"shout_evidence_commit":null,"shout_request":0,"shout_request_outcome":""}],"decisions":[],"asked":[],"events":[{"event_id":31,"event_at":"2026-10-06T12:00:00.000Z","event_by":"coordinator","event_kind":"hold","item_id":null,"event_detail":"{\"lane\":\"review\",\"reason\":\"Waiting for the next demo item.\"}"},{"event_id":30,"event_at":"2026-10-06T12:00:00.000Z","event_by":"person","event_kind":"answer","item_id":null,"event_detail":"{\"shout\":4,\"to\":\"app-3\",\"decision\":false,\"request\":false,\"answers\":1,\"channel\":\"terminal\"}"},{"event_id":29,"event_at":"2026-10-06T12:00:00.000Z","event_by":"person","event_kind":"answer","item_id":null,"event_detail":"{\"shout\":3,\"to\":\"coordinator\",\"decision\":false,\"request\":false,\"answers\":2,\"channel\":\"terminal\"}"},{"event_id":28,"event_at":"2026-10-06T12:00:00.000Z","event_by":"coordinator","event_kind":"pass","item_id":null,"event_detail":"{\"shout\":2,\"to\":\"person\",\"decision\":true,\"request\":false,\"answers\":1}"},{"event_id":27,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-3","event_kind":"shout","item_id":null,"event_detail":"{\"shout\":1,\"to\":\"coordinator\",\"decision\":true,\"request\":false,\"answers\":null}"},{"event_id":26,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-3","event_kind":"claim","item_id":4,"event_detail":"{\"leaseUntil\":\"2026-10-06T14:00:00.000Z\",\"digest\":\"a61ed95a765eefbf7fdb8797154d99adeaf28b752bdd66bfb8926623e270fb38\"}"},{"event_id":25,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-3","event_kind":"family","item_id":null,"event_detail":"{\"family\":\"codex\"}"},{"event_id":24,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-3","event_kind":"join","item_id":null,"event_detail":"{\"lane\":\"app\"}"},{"event_id":23,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-2","event_kind":"submit","item_id":3,"event_detail":"{\"commit\":\"d0108498c7a127f264184dc00d77ef67271a38ad\",\"tree\":\"8dcdda1969040b065338d3bb3aab24c851fa7ddf\",\"policyCommit\":\"74f59a4c65af520a7220f503bf0aeb8f31af8aa8\"}"},{"event_id":22,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-2","event_kind":"claim","item_id":3,"event_detail":"{\"leaseUntil\":\"2026-10-06T14:00:00.000Z\",\"digest\":\"8ec224349992913da728bb07a6d30da2d899364954e80d4fa187aa8dc9b442e0\"}"},{"event_id":21,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-2","event_kind":"family","item_id":null,"event_detail":"{\"family\":\"codex\"}"},{"event_id":20,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-2","event_kind":"join","item_id":null,"event_detail":"{\"lane\":\"app\"}"},{"event_id":19,"event_at":"2026-10-06T12:00:00.000Z","event_by":"coordinator","event_kind":"merged","item_id":1,"event_detail":"{\"commit\":\"74f59a4c65af520a7220f503bf0aeb8f31af8aa8\"}"},{"event_id":18,"event_at":"2026-10-06T12:00:00.000Z","event_by":"review-1","event_kind":"accept","item_id":1,"event_detail":"{\"reason\":\"CRITERION_MET\",\"commit\":\"74f59a4c65af520a7220f503bf0aeb8f31af8aa8\"}"},{"event_id":17,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-1","event_kind":"submit","item_id":1,"event_detail":"{\"commit\":\"74f59a4c65af520a7220f503bf0aeb8f31af8aa8\",\"tree\":\"a4151ea69dda49bf35349795630361ee271d5670\",\"policyCommit\":\"2828af4e4d41e981899dd1e7c818f4689ddb513a\"}"},{"event_id":16,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-1","event_kind":"claim","item_id":1,"event_detail":"{\"leaseUntil\":\"2026-10-06T14:00:00.000Z\",\"digest\":\"52a5178db8543870702679e144835094724f1864a9f63dd507f110de09884926\"}"},{"event_id":15,"event_at":"2026-10-06T12:00:00.000Z","event_by":"review-1","event_kind":"reject","item_id":1,"event_detail":"{\"reason\":\"BEHAVIOR_MISMATCH\",\"commit\":\"a74d5c50fc8238e781ca272d5431877d41d94aaa\"}"},{"event_id":14,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-1","event_kind":"submit","item_id":1,"event_detail":"{\"commit\":\"a74d5c50fc8238e781ca272d5431877d41d94aaa\",\"tree\":\"529da464ab862967df96a3dbb968986e02be9c09\",\"policyCommit\":\"2828af4e4d41e981899dd1e7c818f4689ddb513a\"}"},{"event_id":13,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-1","event_kind":"claim","item_id":1,"event_detail":"{\"leaseUntil\":\"2026-10-06T14:00:00.000Z\",\"digest\":\"52a5178db8543870702679e144835094724f1864a9f63dd507f110de09884926\"}"},{"event_id":12,"event_at":"2026-10-06T12:00:00.000Z","event_by":"review-1","event_kind":"family","item_id":null,"event_detail":"{\"family\":\"claude\"}"},{"event_id":11,"event_at":"2026-10-06T12:00:00.000Z","event_by":"review-1","event_kind":"join","item_id":null,"event_detail":"{\"lane\":\"review\"}"},{"event_id":10,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-1","event_kind":"family","item_id":null,"event_detail":"{\"family\":\"codex\"}"},{"event_id":9,"event_at":"2026-10-06T12:00:00.000Z","event_by":"app-1","event_kind":"join","item_id":null,"event_detail":"{\"lane\":\"app\"}"},{"event_id":8,"event_at":"2026-10-06T12:00:00.000Z","event_by":"coordinator","event_kind":"withdraw","item_id":6,"event_detail":"{\"reason\":\"this example was dropped\"}"},{"event_id":7,"event_at":"2026-10-06T12:00:00.000Z","event_by":"coordinator","event_kind":"add","item_id":6,"event_detail":"{\"lane\":\"app\",\"specIds\":[\"G1\"],\"after\":[],\"route\":\"strong\"}"},{"event_id":6,"event_at":"2026-10-06T12:00:00.000Z","event_by":"coordinator","event_kind":"add","item_id":5,"event_detail":"{\"lane\":\"app\",\"specIds\":[\"G1\"],\"after\":[],\"route\":\"strong\"}"},{"event_id":5,"event_at":"2026-10-06T12:00:00.000Z","event_by":"coordinator","event_kind":"add","item_id":4,"event_detail":"{\"lane\":\"app\",\"specIds\":[\"G1\"],\"after\":[],\"route\":\"strong\"}"},{"event_id":4,"event_at":"2026-10-06T12:00:00.000Z","event_by":"coordinator","event_kind":"add","item_id":3,"event_detail":"{\"lane\":\"app\",\"specIds\":[\"G1\"],\"after\":[],\"route\":\"strong\"}"},{"event_id":3,"event_at":"2026-10-06T12:00:00.000Z","event_by":"coordinator","event_kind":"add","item_id":2,"event_detail":"{\"lane\":\"app\",\"specIds\":[\"G1\"],\"after\":[],\"route\":\"strong\"}"},{"event_id":2,"event_at":"2026-10-06T12:00:00.000Z","event_by":"coordinator","event_kind":"add","item_id":1,"event_detail":"{\"lane\":\"app\",\"specIds\":[\"G1\"],\"after\":[],\"route\":\"strong\"}"},{"event_id":1,"event_at":"2026-10-06T12:00:00.000Z","event_by":"coordinator","event_kind":"join","item_id":null,"event_detail":"{\"lane\":\"coordinator\"}"}],"agents":[{"agent_id":"coordinator","agent_lane":"coordinator","agent_path":"demo-board","agent_last_shout_id":0,"agent_route":"strong","agent_family":null,"agent_created_at":"2026-10-06T12:00:00.000Z","lastMoveAt":"2026-10-06T12:00:00.000Z"},{"agent_id":"app-1","agent_lane":"app","agent_path":"../demo-board-app-1","agent_last_shout_id":0,"agent_route":"strong","agent_family":"codex","agent_created_at":"2026-10-06T12:00:00.000Z","lastMoveAt":"2026-10-06T12:00:00.000Z"},{"agent_id":"review-1","agent_lane":"review","agent_path":"../demo-board-review-1","agent_last_shout_id":0,"agent_route":"strong","agent_family":"claude","agent_created_at":"2026-10-06T12:00:00.000Z","lastMoveAt":"2026-10-06T12:00:00.000Z"},{"agent_id":"app-2","agent_lane":"app","agent_path":"../demo-board-app-2","agent_last_shout_id":0,"agent_route":"strong","agent_family":"codex","agent_created_at":"2026-10-06T12:00:00.000Z","lastMoveAt":"2026-10-06T12:00:00.000Z"},{"agent_id":"app-3","agent_lane":"app","agent_path":"../demo-board-app-3","agent_last_shout_id":0,"agent_route":"strong","agent_family":"codex","agent_created_at":"2026-10-06T12:00:00.000Z","lastMoveAt":"2026-10-06T12:00:00.000Z"}],"holds":[{"hold_lane":"review","hold_reason":"Waiting for the next demo item.","hold_by":"coordinator","hold_at":"2026-10-06T12:00:00.000Z"}],"spec":[{"id":"G1","status":"approved","tier":"must","text":"A demo item exists to show the board.","gate":"none","serves":[],"section":"G · Goals"},{"id":"G2","status":"approved","tier":"must","text":"The verified item shows its review history.","gate":"none","serves":[],"section":"G · Goals"}],"practice":[{"id":"PB1","status":"approved","tier":"must","text":"Ask, don't guess: a decision only the person can make waits for them.","gate":"review","serves":[],"section":"Rules","origin":"standard","version":1,"reason":""},{"id":"PB2","status":"approved","tier":"must","text":"Destructive or irreversible actions wait for the person's OK.","gate":"review","serves":[],"section":"Rules","origin":"standard","version":1,"reason":""},{"id":"PB3","status":"approved","tier":"must","text":"Claims come with evidence: say what ran and what it showed, never \"should work\".","gate":"review","serves":[],"section":"Rules","origin":"standard","version":1,"reason":""},{"id":"PB4","status":"approved","tier":"must","text":"A test must be able to fail: see it fail on broken code before trusting it.","gate":"review","serves":[],"section":"Rules","origin":"standard","version":1,"reason":""},{"id":"PB5","status":"approved","tier":"must","text":"Never weaken a test or a check to make it pass; fix the code.","gate":"review","serves":[],"section":"Rules","origin":"standard","version":1,"reason":""},{"id":"PB6","status":"approved","tier":"must","text":"Tests pass before a change merges.","gate":"the project's gate","serves":[],"section":"Rules","origin":"standard","version":1,"reason":""},{"id":"PB7","status":"pending","tier":"aim","text":"Tests touch nothing outside a temporary sandbox.","gate":"review","serves":[],"section":"Rules","origin":"standard","version":1,"reason":""},{"id":"PB8","status":"approved","tier":"must","text":"No secrets or sensitive info in the repo; test data is synthetic.","gate":"review","serves":[],"section":"Rules","origin":"standard","version":1,"reason":""},{"id":"PB9","status":"approved","tier":"must","text":"Headers: type(scope): subject [ids], 72 characters at most. A body only for a non-obvious why, three sentences at most.","gate":"commit-msg hook, review","serves":[],"section":"Rules","origin":"standard","version":1,"reason":""},{"id":"PB10","status":"approved","tier":"must","text":"Comments explain why, not what; no commented-out code.","gate":"review","serves":[],"section":"Rules","origin":"standard","version":1,"reason":""},{"id":"PB11","status":"approved","tier":"must","text":"A new dependency states why it is needed and what it pulls in.","gate":"review","serves":[],"section":"Rules","origin":"standard","version":1,"reason":""},{"id":"PB12","status":"approved","tier":"must","text":"Questions go on the board, one step up the chain, and the asker keeps working on what it can meanwhile.","gate":"review","serves":[],"section":"Rules","origin":"standard","version":1,"reason":""}],"unseen":null,"products":[],"board":"demo-board","requests":[],"milestones":[]},"eventLogVersion":1}
diff --git a/docs/demo/index.html b/docs/demo/index.html
new file mode 100644
index 00000000..263ca95b
--- /dev/null
+++ b/docs/demo/index.html
@@ -0,0 +1,1308 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<title>Pullboard</title>
+<link rel="stylesheet" href="view.css">
+<link rel="icon" href="data:,">
+</head>
+<body class="loading snapshot">
+<div class="shell">
+<aside class="side" id="side" aria-label="Projects">
+ <div class="side-top">
+ <div class="brand"><svg viewBox="0 0 64 64" aria-hidden="true"><path fill="currentColor" d="M8 7h35a6 6 0 0 1 6 6v7H8a5 5 0 0 1-5-5v-3a5 5 0 0 1 5-5Z"/><rect width="56" height="14" x="3" y="25" fill="var(--accent)" rx="5"/><path fill="currentColor" d="M8 43h35a6 6 0 0 1 6 6v8H8a5 5 0 0 1-5-5v-4a5 5 0 0 1 5-5Z"/></svg><span>Pullboard</span></div>
+ <button class="switch-btn" id="proj-switch" type="button" aria-expanded="false" aria-controls="side-body"><span id="proj-name">Projects</span><b class="need" id="proj-elsewhere" title="Needs you in other projects" hidden></b><small>▾</small></button>
+ <button class="theme-btn" id="theme" type="button" title="Theme: system"><svg class="sys" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="6" fill="none" stroke="currentColor" stroke-width="1.5"/><path fill="currentColor" d="M8 2a6 6 0 0 1 0 12Z"/></svg><svg class="sun" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="3" fill="none" stroke="currentColor" stroke-width="1.5"/><path fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" d="M8 1.5v1.2M8 13.3v1.2M1.5 8h1.2M13.3 8h1.2M3.4 3.4l.85.85M11.75 11.75l.85.85M3.4 12.6l.85-.85M11.75 4.25l.85-.85"/></svg><svg class="moon" viewBox="0 0 16 16" aria-hidden="true"><path fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round" d="M13.6 9.6A6 6 0 1 1 6.4 2.4a5.2 5.2 0 0 0 7.2 7.2Z"/></svg></button>
+ </div>
+ <div class="side-body" id="side-body">
+ <div class="label">Projects</div>
+ <nav id="proj-list" aria-label="Projects on this machine"></nav>
+ <section class="products" id="products" aria-label="Products" hidden><div class="label">Products</div><div id="prod-list"></div></section>
+ </div>
+</aside>
+<div class="body">
+<header class="top">
+ <nav class="tabs" id="tabs" aria-label="Board">
+ <button class="tab" data-tab="items" type="button">Items<b id="count-items"></b></button>
+ <button class="tab" data-tab="shouts" type="button">Shouts<b id="count-shouts"></b></button>
+ <button class="tab" data-tab="spec" type="button">Spec<b id="count-spec"></b></button>
+ <button class="tab" data-tab="doctrine" type="button">Doctrine<b id="count-doctrine"></b></button>
+ <button class="tab" data-tab="activity" type="button">Activity</button>
+ <button class="tab" data-tab="roadmap" type="button">Roadmap</button>
+ </nav>
+ <span class="live" id="live"></span>
+</header>
+<main>
+ <section class="card-panel first">
+ <h2>No boards yet</h2>
+ <p>Run <code>pullboard init</code> in a git repo, or ask an agent to. Its board shows up here by itself.</p>
+ </section>
+ <section class="card-panel snapshot-controls" id="snapshot-controls" aria-label="Snapshot replay">
+ <span>Read-only snapshot</span>
+ <button class="ghost" id="replay-play" type="button">Play from first event</button>
+ <button class="ghost" id="replay-pause" type="button" disabled>Pause</button>
+ <label>Speed <select id="replay-speed"><option value="1">1×</option><option value="4">4×</option><option value="16">16×</option></select></label>
+ <output id="replay-progress" aria-live="polite">Loading events…</output>
+ </section>
+ <section id="group-view" class="group-view" hidden>
+ <section class="card-panel group-panel"><h2>Needs you</h2><div id="group-needs"></div></section>
+ <section class="card-panel group-panel"><h2>Activity</h2><div class="feed" id="group-activity"></div></section>
+ </section>
+ <section data-pane="items" class="two">
+ <div class="primary">
+ <div class="card-panel toolbar"><div class="seg" id="state-chips" role="group" aria-label="Show"></div><input id="q" type="search" placeholder="Search" aria-label="Search titles, lanes or ids"><button class="go" id="new-item" type="button">New item</button></div>
+ <section class="needs-you" id="needs" aria-label="What needs you" hidden></section>
+ <ol class="card-panel chain" id="chain" aria-label="Items"></ol>
+ </div>
+ <aside class="card-panel detail" aria-label="Item detail">
+ <div id="detail"></div>
+ <form id="add-form" class="panel-form" hidden>
+ <h3>New item</h3>
+ <label>Lane<select id="add-lane"></select></label>
+ <label>Title<input id="add-title" required placeholder="What to build"></label>
+ <label>Criterion<input id="add-criterion" placeholder="How a verifier knows it is done"></label>
+ <label>Spec rows<input id="add-specs" placeholder="G1,G2"></label>
+ <label>Brief<textarea id="add-brief" rows="4" placeholder="How to build it: the files, the change, the test"></textarea></label>
+ <div class="actions"><button class="go" type="submit">Add item</button><button class="ghost" id="add-cancel" type="button">Cancel</button></div>
+ </form>
+ </aside>
+ </section>
+ <section data-pane="shouts" class="two narrow">
+ <div class="primary">
+ <section class="needs-you" id="decisions" aria-label="Decisions needed" hidden></section>
+ <form id="shout-form" class="card-panel inline"><p class="answering" id="answering" hidden><span>Answering <b id="answering-who"></b>: <span id="answering-q"></span></span><button class="ghost" id="answer-cancel" type="button">Cancel</button></p><label>To<input id="shout-to" list="shout-targets" required placeholder="all, a lane or an agent"></label><datalist id="shout-targets"></datalist><label class="wide">Message<input id="shout-text" required></label><button class="go" id="shout-send" type="submit">Shout</button></form>
+ <div class="card-panel feed" id="feed"></div>
+ </div>
+ <aside class="card-panel detail" aria-label="Agents and lanes">
+ <div><h3>Agents</h3><div id="agents"></div></div>
+ <div><h3>Lanes</h3><div id="lanes"></div></div>
+ <form id="hold-form" class="panel-form"><label>Hold a lane<select id="hold-lane"></select></label><label>Why<input id="hold-reason" required placeholder="What its agents should wait for"></label><button class="go" type="submit">Hold lane</button></form>
+ </aside>
+ </section>
+ <section data-pane="spec" class="two">
+ <div class="primary"><div class="chips" id="spec-chips"></div><div class="card-panel rows" id="spec-list"></div></div>
+ <aside class="card-panel detail" aria-label="Spec row"><div id="spec-detail"></div></aside>
+ </section>
+ <section data-pane="doctrine" class="two">
+ <div class="primary"><div class="chips" id="doctrine-chips"></div><div class="card-panel rows" id="doctrine-list"></div></div>
+ <aside class="card-panel detail" aria-label="Practice row"><div id="doctrine-detail"></div></aside>
+ </section>
+ <section data-pane="activity">
+ <figure class="card-panel flow" id="flow-panel"><button class="flow-hide" id="flow-hide" type="button" title="Hide the lifecycle" aria-label="Hide the lifecycle">×</button><div id="flow"></div><figcaption>The lifecycle every item follows, as pullboard declares it. Boxes count the items in each state now, labels the moves made along each route, and ↻ the moves that keep an item where it is; hover over one for what it means and checks.</figcaption></figure>
+ <button class="ghost flow-show" id="flow-show" type="button" hidden>Show the lifecycle</button>
+ <div class="card-panel feed" id="activity"></div>
+ </section>
+ <section data-pane="roadmap" class="roadmap" id="roadmap" aria-label="Roadmap"></section>
+</main>
+</div>
+</div>
+<div class="console" id="console" title="Click to close" hidden></div>
+<script>
+const snapshot = true;
+const readOnly = false;
+const transportModule = null;
+const connection = {"base":"","headers":{"x-pullboard-key":""}};
+let transport = null;
+const snapshotReplay = { final: null, events: [], index: 0, playing: false, timer: null };
+const keep = (name, value) => { name = snapshot ? 'snapshot.' + name : name; try { if (value === undefined) return localStorage.getItem(name); localStorage.setItem(name, value); } catch { return null; } return value; };
+// Whether the host serves this page at /roadmap as well as at /, so the Roadmap's address is a path;
+// anywhere else it is a #roadmap fragment on the page's own address (N38).
+const routed = false;
+/** The tab the address names: the Roadmap at its own address, or null at the board's. */
+function addressTab() {
+ if (typeof location === 'undefined') return null;
+ return (routed ? location.pathname === '/roadmap' : location.hash === '#roadmap') ? 'roadmap' : null;
+}
+/** The tab the board's own address shows: the one last picked there, or Items. */
+function homeTab() {
+ const kept = keep('pb.tab');
+ return kept && kept !== 'roadmap' ? kept : 'items';
+}
+const view = { root: keep('pb.project'), tab: addressTab() || homeTab(), seen: {}, code: {}, item: null, adding: false, state: 'active', rows: { spec: 'decide', doctrine: 'all' }, row: { spec: null, doctrine: null } };
+if (snapshot) view.state = 'all';
+let data = null;
+let seen = '';
+const $ = (id) => document.getElementById(id);
+/**
+ * Draw the page in the theme the person picked: light or dark, or anything else to follow the system.
+ * The tokens hold both values, so only the scheme they answer to changes.
+ */
+function theme(pick) {
+ if (pick === 'light' || pick === 'dark') document.documentElement.dataset.theme = pick;
+ else delete document.documentElement.dataset.theme;
+ $('theme').title = 'Theme: ' + (document.documentElement.dataset.theme || 'system');
+}
+theme(keep('pb.theme'));
+const esc = (text) => String(text ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
+const ago = (iso) => { const m = Math.round((Date.now() - Date.parse(iso)) / 60000); return m < 1 ? 'now' : m < 60 ? m + 'm' : m < 2880 ? Math.round(m / 60) + 'h' : Math.round(m / 1440) + 'd'; };
+// An age as the page shows it: the moment it counts from stays on it, so tickAges can move it on.
+const age = (iso) => '<time data-ago="' + esc(iso) + '">' + ago(iso) + '</time>';
+const clock = (iso) => new Date(iso).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hourCycle: 'h23' });
+const when = (iso) => (new Date(iso).toDateString() === new Date().toDateString() ? '' : new Date(iso).toLocaleDateString([], { month: 'short', day: 'numeric' }) + ' ') + clock(iso);
+// A day as a feed names it: Today, Yesterday, or its weekday and date.
+const dayName = (iso) => {
+ const then = new Date(iso).toDateString(), today = new Date();
+ if (then === today.toDateString()) return 'Today';
+ today.setDate(today.getDate() - 1);
+ return then === today.toDateString() ? 'Yesterday' : new Date(iso).toLocaleDateString([], { weekday: 'short', month: 'short', day: 'numeric' });
+};
+// A feed's rows, newest first, with the day named above each run of rows from the same day.
+const byDay = (rows, at, row) => rows.map((x, i) => (i && new Date(at(x)).toDateString() === new Date(at(rows[i - 1])).toDateString() ? '' : '<h4 class="day">' + dayName(at(x)) + '</h4>') + row(x)).join('');
+const firstLine = (text) => String(text ?? '').split('\n').map((line) => line.trim()).find(Boolean) || '';
+// The latest verdict is a reject and no accept followed: open again, being reworked, resubmitted, or
+// withdrawn after it.
+const rejected = (i) => i.status !== 'verified' && !!i.verdict && i.verdict.decision === 'REJECT';
+const verdictHtml = (v) => '<div class="verdict ' + (v.decision === 'ACCEPT' ? 'yes' : 'no') + '"><b>' + esc(v.decision) + ' ' + esc(v.reason) + '</b><span class="by">' + esc(v.by) + ' · ' + when(v.at) + ' · at ' + esc(String(v.commit || '').slice(0, 12)) + '</span><div class="note">' + esc(v.note) + '</div></div>';
+const stateOf = (i) => i.status === 'claimed' ? 'building' : i.status === 'submitted' ? 'verify' : i.status === 'verified' ? 'verified' : i.status === 'withdrawn' ? 'withdrawn' : i.verdict && i.verdict.decision === 'REJECT' ? 'back' : 'open';
+const STATES = { building: ['building', 'busy'], verify: ['to verify', 'warn'], back: ['sent back', 'no'], verified: ['verified', 'ok'], open: ['open', ''], withdrawn: ['withdrawn', ''] };
+const chip = (s) => '<span class="chip ' + STATES[s][1] + '">' + STATES[s][0] + '</span>';
+// A shout's path:lines@commit reference (B23): a button, and under it, once opened, that code as it
+// was at that commit, with its line numbers. The text before it on its line goes with it, so the view
+// can refuse a reference that text may make part of a longer path.
+const codeRef = (ref, before) => {
+ const c = view.code[view.root + '\n' + before + '\n' + ref];
+ const open = Boolean(c && c.open);
+ const shown = !open ? '' : c.error ? '<span class="code no">' + esc(c.error) + '</span>' : !c.lines ? '<span class="code more">loading…</span>'
+ : '<span class="code">' + c.lines.map((line, n) => '<span><i>' + (c.from + n) + '</i>' + esc(line) + '</span>').join('') + (c.more ? '<span class="more">the first ' + c.lines.length + ' lines</span>' : '') + '</span>';
+ return '<button class="ref" data-code="' + esc(ref) + '"' + (before ? ' data-before="' + esc(before) + '"' : '') + ' type="button" aria-expanded="' + open + '">' + esc(ref) + '</button>' + shown;
+};
+const tone = (s) => s === 'approved' ? 'ok' : s === 'pending' ? 'no' : s === 'draft' ? 'warn' : '';
+/** A doctrine rule's source, with a version only when it comes from the shipped standard. */
+const ruleSource = (row) => row.origin === 'standard' ? 'standard ' + row.version : 'repo';
+const count = (n, one, many = one) => n + ' ' + (n === 1 ? one : many);
+// What needs the person in a project, as its Needs-you list counts it: only the person's calls (B26),
+// the decisions passed up to them, spec rows waiting for them, and held lanes, which only the main
+// checkout, the person's seat, can set. Work waiting for a verdict or sent back belongs to the agents,
+// and the line under the project says so without counting it.
+const needCount = (x) => x.ok ? x.decisions + x.pending + x.drafts + x.holds : 0;
+const doing = (x) => [x.decisions && count(x.decisions, 'decision', 'decisions'), x.pending && count(x.pending, 'question', 'questions'), x.drafts && count(x.drafts, 'draft row', 'draft rows'), x.holds && count(x.holds, 'lane held', 'lanes held'), x.sentBack && count(x.sentBack, 'sent back'), x.awaiting && count(x.awaiting, 'to verify'), x.building && count(x.building, 'building')].filter(Boolean).join(' · ') || (x.open ? count(x.open, 'item open', 'items open') : 'nothing open');
+/** The person's calls in one repo, as its Needs-you panel shows them, reused by a combined project view. */
+function projectNeeds(p) {
+ return [
+ ...p.decisions.map((d) => ({ ref: d.shout_from, text: d.shout_text, what: 'decision', at: d.shout_at })),
+ ...p.spec.filter((row) => row.status === 'pending').map((row) => ({ ref: row.id, text: row.text, what: 'answer in SPEC.md' })),
+ ...p.holds.map((hold) => ({ ref: hold.hold_lane, text: hold.hold_reason, what: 'lane held by ' + hold.hold_by })),
+ ...(p.spec.some((row) => row.status === 'draft') ? [{ ref: String(p.spec.filter((row) => row.status === 'draft').length), text: 'draft spec rows to approve or drop', what: 'review in SPEC.md', target: 'tab:spec' }] : []),
+ ];
+}
+// The item lifecycle as pullboard declares it in src/machine.js, embedded when the page is served.
+const FLOW = {"initial":"open","states":[{"id":"open","means":"waiting for a builder; claimable once what it waits on is verified","final":false,"entry":[]},{"id":"claimed","means":"an agent holds it under a lease, its criterion frozen","final":false,"entry":[]},{"id":"submitted","means":"built and gated green at a pinned commit, waiting for another agent","final":false,"entry":[]},{"id":"verified","means":"another agent accepted it at the submitted commit","final":true,"entry":["the caller's checkout contains the submitted commit","the caller did not build it","the criterion and the rows it cites read as they did at claim","an accept notes how it was proved"]},{"id":"withdrawn","means":"nobody should build it; the reason stays on it","final":true,"entry":["the caller is the coordinator","the move carries a note: what failed, what was tried, or why"]}],"moves":[{"verb":"claim","from":["open","claimed"],"to":"claimed","by":["agent","coordinator"],"how":"pullboard claim \u003cid>","checks":["the caller is the main checkout, or a worktree that joined a lane (NOT_JOINED)","the item exists (NO_ITEM)","the item is open or claimed (NOT_CLAIMABLE)","the item is in the caller's lane; the main checkout builds coordinator-lane items only (WRONG_LANE)","the caller's route covers the item's: light, then mid, then strong (ROUTE)","every item it waits on is verified (BLOCKED)","no other agent holds it under a live lease (HELD)","nobody holds its lane (LANE_HELD)","the caller holds no other live top-level claim, reworks of its own rejected items aside (ONE_CLAIM)","every row the item cites exists and is in force (UNKNOWN_SPEC)"]},{"verb":"release","from":["claimed"],"to":"open","by":["agent","coordinator"],"how":"pullboard release \u003cid>","checks":["the caller is the main checkout, or a worktree that joined a lane (NOT_JOINED)","the item exists (NO_ITEM)","the item is claimed (NOT_YOURS)","the caller holds the claim (NOT_YOURS)"]},{"verb":"lapse","from":["claimed"],"to":"open","by":["clock"],"how":"when its lease runs out","checks":[]},{"verb":"submit","from":["claimed"],"to":"submitted","by":["agent","coordinator"],"how":"pullboard submit \u003cid>","checks":["the caller is the main checkout, or a worktree that joined a lane (NOT_JOINED)","the item exists (NO_ITEM)","the item is claimed (NOT_YOURS)","the caller holds the claim (NOT_YOURS)","the criterion and the rows it cites read as they did at claim (CRITERIA_CHANGED)","the worktree has no uncommitted changes (DIRTY)","the worktree has no untracked files (UNTRACKED)","there is a commit to submit (NO_COMMIT)","the full claimed diff respects committed coordinator ownership (OUTSIDE_LANE)","the repo names a gate command (NO_GATE)","the gate, which submit runs itself every time, is green at HEAD (GATE_RED)","when the gate ends, HEAD and every tracked file are as they were when it started (MOVED_DURING_GATE)","every child item is verified or withdrawn (CHILDREN_OPEN)","a verifier has not already rejected this commit (HEAD_NOT_NEW)"]},{"verb":"reserve","from":["submitted"],"to":"submitted","by":["agent","coordinator"],"how":"pullboard next --verify","checks":["in the main checkout, the caller says it is the coordinator (MAIN_IS_COORDINATOR)","the caller is the main checkout, or a worktree that joined a lane (NOT_JOINED)","the item exists (NO_ITEM)","the item is submitted (NOT_SUBMITTED)","the caller did not build it (SELF_VERIFY)","the caller's route covers the item's: light, then mid, then strong (ROUTE)","the repo's verify policy lets the caller verify this lane's work (COORDINATOR_VERIFIES)","the builder and verifier have different declared families; an undeclared family counts as a match (O2_FAMILY_MATCH)","no other agent holds its review under a live lease (REVIEW_HELD)"]},{"verb":"accept","from":["submitted"],"to":"verified","by":["agent","coordinator"],"how":"pullboard verify \u003cid> accept --note \"...\"","checks":["in the main checkout, the caller says it is the coordinator (MAIN_IS_COORDINATOR)","the caller is the main checkout, or a worktree that joined a lane (NOT_JOINED)","the item exists (NO_ITEM)","the item is submitted (NOT_SUBMITTED)","the caller's checkout contains the submitted commit (NOT_AT_COMMIT)","the caller did not build it (SELF_VERIFY)","the caller's route covers the item's: light, then mid, then strong (ROUTE)","the repo's verify policy lets the caller verify this lane's work (COORDINATOR_VERIFIES)","the builder and verifier have different declared families; an undeclared family counts as a match (O2_FAMILY_MATCH)","no other agent holds its review under a live lease (REVIEW_HELD)","the criterion and the rows it cites read as they did at claim (CRITERIA_CHANGED)","an accept gives CRITERION_MET as its reason (BAD_REASON)","the frozen item check passes at the exact submitted commit (CHECK_RED)","an accept notes how it was proved (PROOF_REQUIRED)"]},{"verb":"reject","from":["submitted"],"to":"open","by":["agent","coordinator"],"how":"pullboard verify \u003cid> reject --reason CODE --note \"...\"","checks":["in the main checkout, the caller says it is the coordinator (MAIN_IS_COORDINATOR)","the caller is the main checkout, or a worktree that joined a lane (NOT_JOINED)","the item exists (NO_ITEM)","the item is submitted (NOT_SUBMITTED)","the caller's checkout contains the submitted commit (NOT_AT_COMMIT)","the caller did not build it (SELF_VERIFY)","the caller's route covers the item's: light, then mid, then strong (ROUTE)","the repo's verify policy lets the caller verify this lane's work (COORDINATOR_VERIFIES)","the builder and verifier have different declared families; an undeclared family counts as a match (O2_FAMILY_MATCH)","no other agent holds its review under a live lease (REVIEW_HELD)","the criterion and the rows it cites read as they did at claim (CRITERIA_CHANGED)","a reject names one of the reject reasons (BAD_REASON)","the move carries a note: what failed, what was tried, or why (NOTE_REQUIRED)"]},{"verb":"escalate","from":["open","claimed"],"to":"open","by":["agent","coordinator"],"how":"pullboard escalate \u003cid> --note \"...\"","checks":["the caller is the main checkout, or a worktree that joined a lane (NOT_JOINED)","the move carries a note: what failed, what was tried, or why (NOTE_REQUIRED)","the item exists (NO_ITEM)","the caller holds the item, or is the coordinator (NOT_YOURS)","the item is open or claimed (CLOSED)"]},{"verb":"refreeze","from":["open","claimed","submitted"],"to":"open","by":["coordinator"],"how":"pullboard refreeze \u003cid>","checks":["the caller is the main checkout, or a worktree that joined a lane (NOT_JOINED)","the caller is the coordinator (COORDINATOR_ONLY)","the item exists (NO_ITEM)","the item is open or claimed or submitted (CLOSED)","every row the item cites exists and is in force (UNKNOWN_SPEC)"]},{"verb":"withdraw","from":["open","claimed","submitted"],"to":"withdrawn","by":["coordinator"],"how":"pullboard withdraw \u003cid> \u003creason>","checks":["the caller is the main checkout, or a worktree that joined a lane (NOT_JOINED)","the caller is the coordinator (COORDINATOR_ONLY)","the move carries a note: what failed, what was tried, or why (NOTE_REQUIRED)","the item exists (NO_ITEM)","the item is open or claimed or submitted (CLOSED)"]}]};
+
+/**
+ * An item's history replayed through the lifecycle: each event with the state it found the item in
+ * and the move it made, if it made one. The board logs a move under its verb, and a claim on a
+ * claimed item as renew, but never the clock's lapse: an event that cannot start where the replay
+ * stands, or an item that reads otherwise than where its history leaves it, means the clock moved
+ * first, and the replay puts that lapse in, with no time of its own.
+ */
+function replay(item) {
+ const clock = FLOW.moves.filter((m) => m.by.includes('clock'));
+ const steps = [];
+ let at = FLOW.initial;
+ const step = (move, e) => {
+ steps.push({ from: at, move, at: e ? e.at : null, by: e ? e.by : 'the clock', kind: e ? e.kind : move.verb });
+ if (move) at = move.to;
+ };
+ for (const e of item.history) {
+ const verb = e.kind === 'renew' ? 'claim' : e.kind;
+ // A renew is the claim that stays claimed; a claim logged as such is the one that arrives.
+ const fits = (s) => FLOW.moves.find((m) => m.verb === verb && m.from.includes(s) && (verb !== 'claim' || (e.kind === 'renew') === (m.to === s)));
+ const lapse = fits(at) ? null : clock.find((m) => m.from.includes(at) && fits(m.to));
+ if (lapse) step(lapse, null);
+ step(fits(at) || null, e);
+ }
+ const lapse = at === item.status ? null : clock.find((m) => m.from.includes(at) && m.to === item.status);
+ if (lapse) step(lapse, null);
+ return steps;
+}
+
+/** How often each move was made on this board, keyed from>to:verb, from every item's replay. */
+function moveCounts(items) {
+ const counts = new Map();
+ for (const item of items) {
+ for (const s of replay(item)) {
+ if (s.move) counts.set(s.from + '>' + s.move.to + ':' + s.move.verb, (counts.get(s.from + '>' + s.move.to + ':' + s.move.verb) || 0) + 1);
+ }
+ }
+ return counts;
+}
+
+// A finished stay as the timeline says it: 45m, 3h 20m, 2d 4h.
+const span = (ms) => {
+ const m = Math.max(0, Math.round(ms / 60000));
+ return m < 1 ? 'under a minute' : m < 60 ? m + 'm' : m < 1440 ? Math.floor(m / 60) + 'h' + (m % 60 ? ' ' + (m % 60) + 'm' : '') : Math.floor(m / 1440) + 'd' + (Math.floor((m % 1440) / 60) ? ' ' + Math.floor((m % 1440) / 60) + 'h' : '');
+};
+
+/**
+ * An item's history drawn as a timeline. Each move is a dot in the colour of the state it led to, a
+ * reject in the colour of work sent back, and the item's creation (logged as add) one in the start
+ * state's colour; an event that moves nothing is a hollow dot. Between the dots runs a line in the
+ * colour of the state the item stayed in, and under each dot that began a stay, how long it lasted,
+ * or how long so far while the item can still leave. A lapse has a row but no time, so a stay that
+ * ends or begins at one says its length was not logged rather than guess it.
+ */
+function timeline(item) {
+ const steps = replay(item);
+ return '<ol class="tl">' + steps.map((s, i) => {
+ const enters = s.move ? s.move.to : s.kind === 'add' ? FLOW.initial : null;
+ const state = enters || s.from;
+ const final = FLOW.states.some((f) => f.id === state && f.final);
+ const next = steps.slice(i + 1).find((n) => n.move);
+ const named = s.kind === 'reject' ? 'sent back' : state;
+ const stay = !enters || final ? ''
+ : !s.at ? esc(named + (next ? ' after the ' : ' so far since the ') + s.kind + ', length not logged')
+ : !next ? esc(named) + ' for ' + age(s.at) + ' so far'
+ : !next.at ? esc(named + ' until the ' + next.kind + ', length not logged')
+ : esc(named + ' for ' + span(Date.parse(next.at) - Date.parse(s.at)));
+ return '<li class="tl-' + esc(state) + (s.kind === 'reject' ? ' tl-back' : '') + (enters ? '' : ' tl-quiet') + '"><time>' + (s.at ? when(s.at) : '') + '</time><span><b>' + esc(s.kind) + '</b> ' + esc(s.by) + '</span>' + (stay ? '<small>' + stay + '</small>' : '') + '</li>';
+ }).join('') + '</ol>';
+}
+
+/**
+ * The lifecycle drawn as SVG with this board's counts, the way the README's figure draws it. The
+ * longest way from the start to a final state runs along a row, the first-declared final winning a
+ * tie, its states joined by straight arrows. A pair of states a move leads back along takes a dashed
+ * square route above the row, the further back the higher. The moves that keep a state are written
+ * in its box after a ↻. A state off the row sits below the last state on the row that leads to it,
+ * and the routes into it join into one, labelled once. Final states have a double border. Boxes
+ * count the items there now; labels count the moves made along each route, or name its moves when
+ * none was. Words are wrapped and placed by a generous estimate of their width, so none overlaps.
+ */
+function flowSvg(p) {
+ const counts = moveCounts(p.items);
+ const finals = FLOW.states.filter((s) => s.final).map((s) => s.id);
+ const leads = (s) => FLOW.moves.filter((m) => m.from.includes(s) && m.to !== s).map((m) => m.to);
+ let row = [];
+ const walk = (trail) => {
+ const at = trail[trail.length - 1];
+ if (finals.includes(at)) {
+ if (trail.length > row.length || (trail.length === row.length && finals.indexOf(at) < finals.indexOf(row[row.length - 1]))) row = trail;
+ return;
+ }
+ for (const next of new Set(leads(at))) if (!trail.includes(next)) walk([...trail, next]);
+ };
+ walk([FLOW.initial]);
+ const W = 880, L = 20, BW = 160, step = (W - 2 * L - BW) / Math.max(row.length - 1, 1);
+ const f = (v) => String(Math.round(v * 10) / 10);
+ const col = (s) => row.indexOf(s);
+ const pairs = [];
+ for (const m of FLOW.moves) for (const from of m.from) {
+ let pair = pairs.find((e) => e.from === from && e.to === m.to);
+ if (!pair) pairs.push((pair = { from, to: m.to, moves: [] }));
+ pair.moves.push(m);
+ }
+ const made = (pair, m) => counts.get(pair.from + '>' + pair.to + ':' + m.verb) || 0;
+ const says = (pair) => pair.moves.map((m) => m.verb + ', ' + pair.from + ' to ' + pair.to + ', by the ' + m.by.join(' or ') + ': ' + m.how + '. Made ' + count(made(pair, m), 'time', 'times') + (m.checks.length ? '.\nChecks, in order:\n' + m.checks.map((c) => ' ' + c).join('\n') : '.')).join('\n\n');
+ // What some pairs' moves come to: each verb with how often it was made, or every verb when none was.
+ const told = (list) => {
+ const sums = new Map();
+ for (const pair of list) for (const m of pair.moves) sums.set(m.verb, (sums.get(m.verb) || 0) + made(pair, m));
+ const done = [...sums].filter(([, n]) => n);
+ return { words: done.length ? done.map(([verb, n]) => verb + ' ' + n) : [...sums.keys()], idle: !done.length };
+ };
+ // A generous width for words at a size, and words joined by dots into the fewest even lines that
+ // fit a room, as the README's figure splits them.
+ const wide = (words, size) => words.length * size * 0.56;
+ const wrap = (words, room, size) => {
+ for (let n = 1; ; n += 1) {
+ const per = Math.ceil(words.length / n), lines = [];
+ for (let i = 0; i < words.length; i += per) lines.push(words.slice(i, i + per).join(' · '));
+ if (per === 1 || lines.every((line) => wide(line, size) <= room)) return lines;
+ }
+ };
+ const text = (x, y, words, cls, anchor = 'middle') => '<text class="' + cls + '" x="' + f(x) + '" y="' + f(y) + '" text-anchor="' + anchor + '">' + esc(words) + '</text>';
+ const lines = (x, y, said, cls, anchor) => said.map((line, i) => text(x, y - 15 * (said.length - 1 - i), line, cls, anchor)).join('');
+ const path = (points) => 'M' + points.map(([x, y]) => f(x) + ' ' + f(y)).join('L');
+
+ // Inside each box: its name and count, then the moves that keep it, then any items sent back.
+ const back = p.items.filter((i) => stateOf(i) === 'back').length;
+ const inside = new Map(FLOW.states.map((s) => {
+ const keeps = pairs.find((pair) => pair.from === s.id && pair.to === s.id);
+ const said = keeps ? told([keeps]) : null;
+ const kept = said ? wrap(said.words, BW - 28 - wide('↻ ', 11), 11).map((line, i) => (i ? ' ' : '↻ ') + line) : [];
+ return [s.id, { keeps, said, kept, back: s.id === FLOW.initial && back ? back + ' sent back' : '' }];
+ }));
+ const BH = 44 + 15 * Math.max(1, ...[...inside.values()].map((box) => box.kept.length + (box.back ? 1 : 0)));
+
+ // Routes back along the row, each at a level by how far back it goes; their words above them.
+ const ups = pairs.filter((pair) => pair.from !== pair.to && col(pair.from) >= 0 && col(pair.to) >= 0 && col(pair.to) !== col(pair.from) + 1)
+ .map((pair) => ({ pair, span: Math.abs(col(pair.from) - col(pair.to)) })).sort((a, b) => a.span - b.span);
+ const spans = [...new Set(ups.map((up) => up.span))];
+ for (const up of ups) {
+ up.level = spans.indexOf(up.span);
+ const a = L + BW / 2 + col(up.pair.from) * step, b = L + BW / 2 + col(up.pair.to) * step;
+ const before = (key, value) => ups.filter((other) => other !== up && other.pair[key] === value && other.span < up.span).length;
+ up.start = a + (a > b ? 16 : -16) + (a > b ? 26 : -26) * before('from', up.pair.from);
+ up.end = b + (a > b ? BW / 2 - 40 : 40 - BW / 2) + (a > b ? -30 : 30) * before('to', up.pair.to);
+ up.said = told([up.pair]);
+ up.lines = wrap(up.said.words, Math.abs(up.start - up.end) - 20, 12);
+ }
+ // Each level stands clear of the words of the level below it.
+ const rise = [];
+ for (const level of spans.keys()) {
+ const below = ups.filter((up) => up.level === level - 1);
+ rise[level] = level ? rise[level - 1] + 18 + 15 * Math.max(...below.map((up) => up.lines.length)) : 30;
+ }
+ const highest = ups.length ? Math.max(...ups.map((up) => rise[up.level] + 21 + 15 * (up.lines.length - 1))) : 0;
+ const top = 12 + highest, Y = top + BH / 2, bottom = top + BH;
+ const pos = new Map(row.map((s, i) => [s, { x: L + BW / 2 + i * step, y: Y }]));
+
+ // A state off the row sits below the last state on it that leads there.
+ const below = FLOW.states.filter((s) => !pos.has(s.id));
+ for (const s of below) {
+ const from = row.filter((r) => leads(r).includes(s.id));
+ pos.set(s.id, { x: from.length ? pos.get(from[from.length - 1]).x : W / 2, y: bottom + 80 + BH / 2 });
+ }
+ const H = (below.length ? bottom + 80 + BH : bottom) + 14;
+
+ const group = (pairList, route, label) => pairList.map((pair, n) => '<g><title>' + esc(says(pair)) + '</title><path class="edge' + (route.back ? ' back' : '') + '" d="' + route.d + '" marker-end="url(#pb-head' + (route.back ? '-back' : '') + ')"/>' + (n === 0 ? label : '') + '</g>').join('');
+ const tone = (said, extra = '') => 'tag' + (said.idle ? ' idle' : '') + extra;
+ const routes = [];
+ // Straight along the row.
+ for (const pair of pairs.filter((pair) => col(pair.from) >= 0 && col(pair.to) === col(pair.from) + 1)) {
+ const a = pos.get(pair.from), b = pos.get(pair.to), said = told([pair]);
+ routes.push(group([pair], { d: path([[a.x + BW / 2, Y], [b.x - BW / 2 - 1, Y]]) }, text((a.x + b.x) / 2, Y - 8, said.words.join(' · '), tone(said))));
+ }
+ // Square, above the row.
+ for (const up of ups) {
+ const isBack = col(up.pair.to) < col(up.pair.from), y = top - rise[up.level];
+ routes.push(group([up.pair], { back: isBack, d: path([[up.start, top], [up.start, y], [up.end, y], [up.end, top - 1]]) }, lines((up.start + up.end) / 2, y - 7, up.lines, tone(up.said, isBack ? ' back' : ''))));
+ }
+ // Down from the row, joining into one route per state below, labelled once on the way in.
+ for (const s of below) {
+ const t = pos.get(s.id), into = pairs.filter((pair) => pair.to === s.id && pos.has(pair.from) && pair.from !== s.id);
+ const said = told(into), tTop = t.y - BH / 2;
+ const xs = into.map((pair) => pos.get(pair.from).x).sort((a, b) => a - b);
+ const left = xs.filter((x) => x < t.x - 0.5), right = xs.filter((x) => x > t.x + 0.5);
+ const label = left.length
+ ? lines((left[0] + (left[1] ?? t.x - BW / 2)) / 2, t.y - 8, wrap(said.words, (left[1] ?? t.x - BW / 2) - left[0] - 20, 12), tone(said))
+ : right.length
+ ? lines((right[right.length - 1] + (right[right.length - 2] ?? t.x + BW / 2)) / 2, t.y - 8, wrap(said.words, right[right.length - 1] - (right[right.length - 2] ?? t.x + BW / 2) - 20, 12), tone(said))
+ : lines(t.x + 10, (bottom + tTop) / 2 + 4, said.words, tone(said), 'start');
+ // The label goes with the route that reaches furthest, drawn first; the others join it.
+ const order = [...into].sort((p1, p2) => Math.abs(pos.get(p2.from).x - t.x) - Math.abs(pos.get(p1.from).x - t.x));
+ order.forEach((pair, n) => {
+ const a = pos.get(pair.from);
+ const d = Math.abs(a.x - t.x) < 0.5 ? path([[a.x, bottom], [t.x, tTop - 1]]) : path([[a.x, bottom], [a.x, t.y], [a.x < t.x ? t.x - BW / 2 - 1 : t.x + BW / 2 + 1, t.y]]);
+ routes.push(group([pair], { d }, n === 0 ? label : ''));
+ });
+ }
+
+ const boxes = FLOW.states.map((s) => {
+ const { x, y } = pos.get(s.id), box = inside.get(s.id), left = x - BW / 2, boxTop = y - BH / 2;
+ const tip = s.id + ': ' + s.means + (s.entry.length ? '.\nEvery way in checks:\n' + s.entry.map((r) => ' ' + r).join('\n') : '.');
+ const keeps = box.kept.length ? '<g><title>' + esc(says(box.keeps)) + '</title>' + box.kept.map((line, i) => text(left + 14, boxTop + 47 + 15 * i, line, 'keep' + (box.said.idle ? ' idle' : ''), 'start')).join('') + '</g>' : '';
+ return '<g class="s-' + esc(s.id) + '"><title>' + esc(tip) + '</title><rect class="box" x="' + f(left) + '" y="' + f(boxTop) + '" width="' + BW + '" height="' + BH + '" rx="10"/>'
+ + (s.final ? '<rect class="box inner" x="' + f(left + 4) + '" y="' + f(boxTop + 4) + '" width="' + (BW - 8) + '" height="' + (BH - 8) + '" rx="7"/>' : '')
+ + text(left + 14, boxTop + 25, s.id, 'name', 'start') + text(x + BW / 2 - 14, boxTop + 29, String(p.items.filter((i) => i.status === s.id).length), 'n', 'end')
+ + keeps + (box.back ? text(left + 14, boxTop + 47 + 15 * box.kept.length, box.back, 'sub', 'start') : '') + '</g>';
+ });
+ const head = (id, cls) => '<marker id="' + id + '" class="' + cls + '" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0 0L10 5L0 10z"/></marker>';
+ return '<svg viewBox="0 0 ' + W + ' ' + f(H) + '" role="img" aria-label="The item lifecycle, with counts from this board"><defs>' + head('pb-head', '') + head('pb-head-back', 'back') + '</defs>' + routes.join('') + boxes.join('') + '</svg>';
+}
+
+/** Read or move through API v1, retaining the rule and repair guidance in a refusal. */
+async function api(path, body) {
+ if (body && (snapshot || readOnly)) throw new Error(snapshot ? 'This is a read-only snapshot.' : 'This is a read-only view.');
+ if (transport) return transport.request(path, body);
+ path = snapshot ? path.split('?')[0].slice(1) + '.json' : connection.base + path;
+ const res = await fetch(path, { method: body ? 'POST' : 'GET', headers: snapshot ? {} : { ...connection.headers, ...(body ? { 'content-type': 'application/json' } : {}) }, body: body ? JSON.stringify(body) : undefined });
+ const json = await res.json();
+ if (!res.ok) {
+ const refusal = json.error;
+ const message = refusal && typeof refusal === 'object' ? '[' + refusal.code + '] ' + refusal.message : refusal || res.status;
+ throw new Error(message);
+ }
+ return json;
+}
+
+/** A board's sidebar counts, derived from the same API state the page displays. */
+function boardSummary(board, state) {
+ /** Count one item state for the sidebar. */
+ const count = (test) => state.items.filter(test).length;
+ return {
+ ...board, ok: true,
+ building: count((item) => item.status === 'claimed'),
+ awaiting: count((item) => item.status === 'submitted'),
+ sentBack: count((item) => item.status === 'open' && item.verdict && item.verdict.decision === 'REJECT'),
+ open: count((item) => item.status === 'open'),
+ verified: count((item) => item.status === 'verified'),
+ pending: state.spec.filter((row) => row.status === 'pending').length,
+ drafts: state.spec.filter((row) => row.status === 'draft').length,
+ holds: state.holds.length,
+ decisions: state.decisions.length,
+ // What each item's state reads from, so another repo's roadmap can show it as this board's
+ // Items tab does, sent back included, and open it here.
+ items: state.items.map((item) => ({ id: item.id, title: item.title, status: item.status, verdict: item.verdict && { decision: item.verdict.decision } })),
+ };
+}
+
+/** Resolve a displayed repo to the persistent board identity supplied by API v1. */
+function boardPath(root) {
+ const board = data && data.projects.find((entry) => entry.root === root && entry.ok);
+ if (!board) throw new Error('This board is unavailable; choose a readable project and retry.');
+ return '/api/v1/boards/' + encodeURIComponent(board.id);
+}
+
+/** Compose the multi-repo page from the public board list and each board's public state. */
+async function boardState(root, mark) {
+ const listed = await api('/api/v1/boards');
+ const states = new Map();
+ const cursor = mark !== null && mark !== undefined && /^\d+$/.test(String(mark)) && Number.isSafeInteger(Number(mark)) ? Number(mark) : null;
+ const projects = await Promise.all(listed.boards.map(async (board) => {
+ try {
+ const query = board.root === root && cursor !== null ? '?seen=' + encodeURIComponent(cursor) : '';
+ const reply = await api('/api/v1/boards/' + encodeURIComponent(board.id) + '/state' + query);
+ states.set(board.root, reply.state);
+ return boardSummary(board, reply.state);
+ } catch (error) {
+ return { ...board, ok: false, error: String(error.message || error) };
+ }
+ }));
+ projects.push(...(listed.warnings || []).map((warning) => ({ ...warning, ok: false, error: warning.error.error.message })));
+ const grouped = new Map();
+ for (const project of projects) {
+ if (!project.project) continue;
+ if (!grouped.has(project.project)) grouped.set(project.project, []);
+ grouped.get(project.project).push(project);
+ }
+ const groups = [...grouped].map(([name, repos]) => ({ name, key: 'group:' + name, repos }));
+ const group = groups.find((entry) => entry.key === root);
+ return {
+ projects, groups, project: states.get(root) || null,
+ group: group ? { name: group.name, repos: group.repos.filter((repo) => repo.ok).map((repo) => ({ root: repo.root, name: repo.name, board: states.get(repo.root) })) } : null,
+ };
+}
+
+/** Refresh from API v1 and discard a response for a project the person already left. */
+async function refresh() {
+ const root = view.root;
+ const mark = root ? view.seen['pb.seen.' + root] ?? keep('pb.seen.' + root) : null;
+ const next = await boardState(root, mark);
+ // The person switched projects while this answer was on its way: the switch's own refresh shows it.
+ if (root !== view.root) return;
+ if (!next.project && !next.group && next.projects.some((p) => p.ok)) {
+ view.root = next.projects.find((p) => p.ok).root;
+ keep('pb.project', view.root);
+ return refresh();
+ }
+ // The project this board is, so a switch still loading never reads it as the next one's.
+ next.root = root;
+ // Rebuild only when the board changed: a list rebuilt under the pointer can swallow a click.
+ const text = JSON.stringify(next);
+ if (text !== seen) {
+ seen = text;
+ data = next;
+ render();
+ }
+ if (snapshot && !snapshotReplay.final && data.project) {
+ snapshotReplay.final = structuredClone(data.project);
+ snapshotReplay.events = (await api(boardPath(view.root) + '/events')).events;
+ snapshotReplay.index = snapshotReplay.events.length;
+ replayControls();
+ }
+ $('live').textContent = snapshot ? 'read-only snapshot' : 'live · ' + new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit', hourCycle: 'h23' });
+}
+
+/** Display the current event and make the replay's play, pause and end states explicit. */
+function replayControls() {
+ const r = snapshotReplay;
+ const event = r.events[r.index - 1];
+ $('replay-progress').textContent = 'Event ' + r.index + ' / ' + r.events.length + (event ? ' · ' + event.event_kind + (event.item_id ? ' #' + event.item_id : '') : '') + (r.index === r.events.length ? ' · End' : '');
+ $('replay-play').disabled = r.playing || !r.final || !r.events.length;
+ $('replay-play').textContent = r.index === r.events.length ? 'Play from first event' : 'Play';
+ $('replay-pause').disabled = !r.playing;
+}
+
+/** Project only the events already played, using the same declared lifecycle as the live page. */
+function replayProject(index) {
+ const r = snapshotReplay;
+ if (index === r.events.length) return structuredClone(r.final);
+ const p = structuredClone(r.final);
+ const log = r.events.slice(0, index);
+ p.items = p.items.flatMap((item) => {
+ const history = log.filter((event) => event.item_id === item.id);
+ if (!history.some((event) => event.event_kind === 'add')) return [];
+ let state = FLOW.initial;
+ item.owner = null;
+ item.builtBy = null;
+ item.verifiedBy = null;
+ item.reviewer = null;
+ item.reviewUntil = null;
+ item.commit = null;
+ item.merged = null;
+ let verdicts = 0;
+ for (const event of history) {
+ const verb = event.event_kind === 'renew' ? 'claim' : event.event_kind;
+ /** Find a declared move, distinguishing a renewed claim from a new one. */
+ const fits = (at) => FLOW.moves.find((move) => move.verb === verb && move.from.includes(at) && (verb !== 'claim' || (event.event_kind === 'renew') === (move.to === at)));
+ const lapse = fits(state) ? null : FLOW.moves.find((move) => move.by.includes('clock') && move.from.includes(state) && fits(move.to));
+ if (lapse) state = lapse.to;
+ const move = fits(state);
+ if (move) state = move.to;
+ const detail = JSON.parse(event.event_detail);
+ if (verb === 'claim') item.owner = event.event_by;
+ if (verb === 'submit') { item.commit = detail.commit; item.builtBy = event.event_by; item.reviewer = null; item.reviewUntil = null; }
+ if (verb === 'reserve') { item.reviewer = event.event_by; item.reviewUntil = detail.until; }
+ if (verb === 'accept') { item.verifiedBy = event.event_by; verdicts += 1; }
+ if (verb === 'reject') { item.owner = null; verdicts += 1; }
+ if (verb === 'accept' || verb === 'reject' || verb === 'release' || verb === 'withdraw') { item.reviewer = null; item.reviewUntil = null; }
+ if (verb === 'release' || verb === 'withdraw') item.owner = null;
+ if (verb === 'merged') item.merged = detail.commit;
+ }
+ item.status = state;
+ item.history = history.map((event) => ({ kind: event.event_kind, by: event.event_by, at: event.event_at }));
+ item.updatedAt = history.at(-1).event_at;
+ item.verdicts = item.verdicts.slice(0, verdicts);
+ item.verdict = item.verdicts.at(-1) ?? null;
+ return [item];
+ });
+ const statuses = new Map(p.items.map((item) => [item.id, item.status]));
+ for (const item of p.items) {
+ const added = log.find((event) => event.item_id === item.id && event.event_kind === 'add');
+ item.blockedBy = (JSON.parse(added.event_detail).after || []).filter((id) => statuses.get(id) !== 'verified');
+ }
+ // A milestone lists only this board's items added by now; another repo's stay as the export read them.
+ p.milestones = (p.milestones || []).map((milestone) => ({ ...milestone, items: milestone.items.filter((entry) => typeof entry.id !== 'number' || statuses.has(entry.id)) }));
+ const shouted = new Set(log.map((event) => JSON.parse(event.event_detail).shout).filter(Boolean));
+ p.shouts = p.shouts.filter((shout) => shouted.has(shout.shout_id));
+ p.decisions = p.decisions.filter((shout) => shouted.has(shout.shout_id));
+ p.asked = p.asked.filter((shout) => shouted.has(shout.shout_id));
+ const held = new Map();
+ for (const event of log) {
+ const detail = JSON.parse(event.event_detail);
+ if (event.event_kind === 'hold') held.set(detail.lane, { hold_lane: detail.lane, hold_reason: detail.reason, hold_by: event.event_by, hold_at: event.event_at });
+ if (event.event_kind === 'unhold') held.delete(detail.lane);
+ }
+ p.holds = [...held.values()].sort((a, b) => a.hold_lane.localeCompare(b.hold_lane));
+ p.events = log.slice(-80).reverse();
+ return p;
+}
+
+/** Draw a replay position without refreshing or changing the exported board. */
+function replayPosition(index) {
+ const r = snapshotReplay;
+ r.index = index;
+ view.root = r.final.root;
+ view.state = 'all';
+ data.root = view.root;
+ data.group = null;
+ data.project = replayProject(index);
+ data.projects = data.projects.map((board) => board.root === view.root ? boardSummary(board, data.project) : board);
+ render();
+ replayControls();
+}
+
+/** Pause before clearing the next callback, so no event advances after the control returns. */
+function pauseReplay() {
+ snapshotReplay.playing = false;
+ clearTimeout(snapshotReplay.timer);
+ replayControls();
+}
+
+/** Play one event per speed-adjusted interval, stopping exactly at the exported final state. */
+function advanceReplay() {
+ const r = snapshotReplay;
+ if (!r.playing) return;
+ replayPosition(r.index + 1);
+ if (r.index === r.events.length) return pauseReplay();
+ r.timer = setTimeout(advanceReplay, 1000 / Number($('replay-speed').value));
+}
+
+/** Resume a paused replay, or restart at the first event when the snapshot is at the end. */
+function playReplay() {
+ const r = snapshotReplay;
+ if (!r.final || !r.events.length || r.playing) return;
+ if (r.index === r.events.length) replayPosition(0);
+ r.playing = true;
+ advanceReplay();
+}
+
+/**
+ * The sidebar: every project, the one shown, and what needs the person elsewhere. A switch draws only
+ * this until the new board arrives, so the main column never mixes the old board with the new pick.
+ */
+function renderSide() {
+ /** Render a repo button or one muted recovery line when its board cannot be read. */
+ const repoButton = (x) => {
+ if (!x.ok) return '<p class="repo-error" role="status"><b>' + esc(x.name) + ':</b> ' + esc(x.error) + '</p>';
+ const on = x.root === view.root;
+ return '<button class="proj repo' + (on ? ' on' : '') + '"' + (on ? ' aria-current="true"' : '') + ' data-root="' + esc(x.root) + '" title="' + esc(x.root) + '" type="button"><span class="pname">' + esc(x.name) + '</span>' + (needCount(x) ? '<b class="need" title="needs you">' + needCount(x) + '</b>' : '') + '<small>' + esc(doing(x)) + '</small></button>';
+ };
+ const groupedRoots = new Set(data.groups.flatMap((group) => group.repos.map((repo) => repo.root)));
+ const grouped = data.groups.map((group) => {
+ const on = group.key === view.root;
+ const needs = group.repos.reduce((total, repo) => total + needCount(repo), 0);
+ const count = group.repos.length;
+ return '<section class="repo-group"><button class="proj project-pick' + (on ? ' on' : '') + '"' + (on ? ' aria-current="true"' : '') + ' data-root="' + esc(group.key) + '" type="button"><span class="pname">' + esc(group.name) + '</span>' + (needs ? '<b class="need" title="needs you">' + needs + '</b>' : '') + '<small>' + count + ' ' + (count === 1 ? 'repo' : 'repos') + '</small></button><div class="repos">' + group.repos.map(repoButton).join('') + '</div></section>';
+ }).join('');
+ const loose = data.projects.filter((repo) => !repo.project && !groupedRoots.has(repo.root)).map(repoButton).join('');
+ $('proj-list').innerHTML = grouped || loose ? grouped + loose : '<div class="empty">None yet.</div>';
+ const currentGroup = data.groups.find((group) => group.key === view.root);
+ const currentRoots = new Set(currentGroup ? currentGroup.repos.map((repo) => repo.root) : [view.root]);
+ const elsewhere = data.projects.filter((x) => !currentRoots.has(x.root)).reduce((n, x) => n + needCount(x), 0);
+ $('proj-elsewhere').textContent = elsewhere ? elsewhere + ' elsewhere' : '';
+ $('proj-elsewhere').hidden = !elsewhere;
+ const p = data.project;
+ const selectedGroup = data.groups.find((group) => group.key === view.root);
+ $('proj-name').textContent = selectedGroup?.name || (p ? (data.projects.find((x) => x.root === view.root) || { name: p.root.split('/').pop() }).name : 'No project');
+ // The browser tab says it too, for when the view sits behind other tabs.
+ const needs = data.projects.reduce((n, x) => n + needCount(x), 0);
+ document.title = p || selectedGroup ? (needs ? '(' + needs + ') ' : '') + $('proj-name').textContent + ' · Pullboard' : 'Pullboard';
+}
+
+ /** Escape plain text while preserving safe item and code-preview links.
+ * @param {string} text
+ * @param {Map<string, string>} titles
+ * @param {boolean} allowLinks
+ * @returns {string}
+ */
+ function linked(text, titles, allowLinks = true) { return String(text ?? '').split(/(#\d+|(?<![^\s([{"'`])[^\s:@()[\]{}"'`]+:\d+(?:-\d+)?@[0-9a-f]{7,40}(?![^\s)\]}"'`.,;:!?]))/).map((part, n, parts) => {
+ if (n % 2 && part[0] !== '#') return allowLinks ? codeRef(part, parts.slice(0, n).join('').split('\n').pop().slice(-2000)) : '<code class="inline">' + esc(part) + '</code>';
+ const id = /^#\d+$/.test(part) ? String(Number(part.slice(1))) : '';
+ return titles.has(id) && allowLinks ? '<button class="ref" data-go="item:' + id + '" title="' + esc(titles.get(id)) + '" type="button">' + esc(part) + '</button>' : esc(part);
+ }).join(''); }
+ /** Format inline code and recognized command tokens without interpreting markup.
+ * @param {string} text
+ * @param {Map<string, string>} titles
+ * @param {boolean} allowLinks
+ * @returns {string}
+ */
+ function inline(text, titles, allowLinks = true) { return String(text ?? '').split(/(`[^`]*`|[^\s:@()[\]{}"'`]+:\d+(?:-\d+)?@[0-9a-f]{7,40}|pullboard(?:\s+\w+)+|--[\w-]+|(?:\/|\.\.?\/|[\w.-]+\/)\w[\w./-]*\.[A-Za-z0-9]+|\b[0-9a-fA-F]{7,40}\b|#\d+)/g).map((part, n, parts) => {
+ if (part.startsWith('`') && part.endsWith('`')) return '<code class="inline">' + esc(part.slice(1, -1)) + '</code>';
+ if (part.includes('@') && part.includes(':')) {
+ const textBefore = parts.slice(0, n).join('');
+ const fullText = parts.join('');
+ const after = fullText[textBefore.length + part.length] || '';
+ const leftBoundary = !textBefore || [9, 10, 32, 40, 91, 123, 34, 39, 96].includes(textBefore.at(-1).charCodeAt(0));
+ const rightBoundary = !after || [9, 10, 32, 41, 93, 125, 34, 39, 96, 46, 44, 59, 58, 33, 63].includes(after.charCodeAt(0));
+ const validRef = leftBoundary && rightBoundary;
+ if (allowLinks && validRef) return codeRef(part, textBefore.slice(-2000));
+ return '<code class="inline">' + esc(part) + '</code>';
+ }
+ if (/^(?:pullboard(?:\s+\w+)+|--[\w-]+|(?:\/|\.\.?\/|[\w.-]+\/)\w[\w./-]*\.[A-Za-z0-9]+|\b[0-9a-fA-F]{7,40}\b)$/.test(part)) return '<code class="inline">' + esc(part) + '</code>';
+ return linked(part, titles, allowLinks);
+ }).join(''); }
+ /** Render inline text and fenced or shell command blocks with escaped contents.
+ * @param {string} text
+ * @param {Map<string, string>} titles
+ * @param {boolean} allowLinks
+ * @returns {string}
+ */
+ function rich(text, titles, allowLinks = true) {
+ const lines = String(text ?? '').split('\n');
+ const output = [];
+ for (let i = 0; i < lines.length;) {
+ if (lines[i].startsWith('```')) {
+ const block = [];
+ i++;
+ while (i < lines.length && !lines[i].startsWith('```')) block.push(lines[i++]);
+ if (i < lines.length) i++;
+ output.push('<code class="code block">' + esc(block.join('\n')) + '</code>');
+ } else if (lines[i].startsWith('$ ')) {
+ const block = [];
+ while (i < lines.length && lines[i].startsWith('$ ')) block.push(lines[i++]);
+ output.push('<code class="code block">' + esc(block.join('\n')) + '</code>');
+ } else {
+ const block = [];
+ while (i < lines.length && !lines[i].startsWith('```') && !lines[i].startsWith('$ ')) block.push(inline(lines[i++], titles, allowLinks));
+ output.push(block.join('<br>'));
+ }
+ }
+ return output.join('<br>');
+ }
+
+/** Draw a project's cross-repo Needs-you list and one activity feed. */
+function renderGroup(group) {
+ const needs = group.repos.flatMap((repo) => projectNeeds(repo.board).map((row) => ({ ...row, repo })));
+ $('group-needs').innerHTML = needs.length ? needs.map((row) => {
+ const titles = new Map(row.repo.board.items.map((item) => [String(item.id), item.title]));
+ return '<button class="group-need" data-root="' + esc(row.repo.root) + '" type="button"><b>' + esc(row.repo.name) + '</b><code>' + esc(row.ref) + '</code><span>' + rich(row.text, titles, false) + '</span><em>' + esc(row.what) + (row.at ? ', ' + age(row.at) : '') + ' →</em></button>';
+ }).join('') : '<div class="empty">Nothing needs you across this project.</div>';
+ const events = group.repos.flatMap((repo) => {
+ const titles = new Map(repo.board.items.map((item) => [String(item.id), item.title]));
+ return repo.board.events.map((event) => ({ ...event, repo, title: event.item_id ? titles.get(String(event.item_id)) : null }));
+ }).sort((a, b) => b.event_at.localeCompare(a.event_at)).slice(0, 80);
+ $('group-activity').innerHTML = events.length ? byDay(events, (event) => event.event_at, (event) => '<div><time>' + clock(event.event_at) + '</time><div class="act"><b class="repo-label">' + esc(event.repo.name) + '</b> <span>' + esc(event.event_by) + ' ' + esc(event.event_kind) + (event.item_id ? ' #' + event.item_id + (event.title ? ' ' + rich(event.title, new Map(), false) : '') : '') + '</span></div></div>') : '<div class="empty">No activity yet.</div>';
+}
+
+/**
+ * A milestone's item as the Items tab reads it (N26). This board's own come from its items, and
+ * another repo's, written repo#id, from that repo's board when the view lists one by that name or
+ * folder, as the roadmap resolves it: the same state, sent back included, and it opens there. An
+ * item no listed board holds keeps the status the roadmap read for it, and opens nowhere.
+ */
+function milestoneItem(entry, p) {
+ const local = typeof entry.id === 'number';
+ const ref = local ? null : /^(.+)#([1-9]\d*)$/.exec(String(entry.id));
+ const named = ref ? data.projects.filter((x) => x.name === ref[1] || String(x.root).split('/').pop() === ref[1]) : [];
+ const root = local ? view.root : named.length === 1 && named[0].ok ? named[0].root : null;
+ const id = local ? entry.id : ref ? Number(ref[2]) : null;
+ const item = (root === view.root ? p.items : root ? named[0].items : []).find((i) => i.id === id) || null;
+ // A status the lifecycle declares; the roadmap says unavailable or missing for an item it could not read.
+ const read = item || (FLOW.states.some((state) => state.id === entry.status) ? { status: entry.status, verdict: null } : null);
+ return {
+ label: local ? '#' + entry.id : String(entry.id),
+ title: item ? item.title : read ? entry.title : '',
+ state: read ? stateOf(read) : null,
+ word: entry.status,
+ open: item ? { root, id } : null,
+ // Why an item does not open, short enough to read beside its id on a phone.
+ why: item ? '' : local ? 'not on this board' : root ? 'not on that board' : snapshot ? 'not in this snapshot'
+ : named.length > 1 ? 'board name not unique' : named.length ? 'board unreadable' : 'no such board',
+ };
+}
+
+/**
+ * One item's row on the Roadmap, laid out as the Items list lays one out: the dot of its state, its
+ * id and title on one line that ends in an ellipsis when cut, and the Items tab's chip. The whole
+ * title is the row's tooltip. An item that opens is a button; one that cannot says why instead.
+ */
+function milestoneRow(row, titles) {
+ const title = row.title ? inline(String(row.title).replace(/\s+/g, ' '), titles, false) : '<span class="muted">' + esc(row.why) + '</span>';
+ const inner = '<span class="dot' + (row.state ? ' ' + row.state : '') + '"></span><span class="t"><span class="id">' + esc(row.label) + '</span>' + title + '</span>' + (row.state ? chip(row.state) : '<span class="chip">' + esc(row.word) + '</span>');
+ if (!row.open) return '<li><div class="milestone-item" title="' + esc(row.title ? row.title + ' (' + row.why + ')' : row.why) + '">' + inner + '</div></li>';
+ return '<li><button class="milestone-item" data-go="item:' + row.open.id + '"' + (row.open.root === view.root ? '' : ' data-board="' + esc(row.open.root) + '"') + ' title="' + esc(row.title) + '" type="button">' + inner + '</button></li>';
+}
+
+/**
+ * The Roadmap (N26, N38): a card for each milestone in the board's order, with how many of its
+ * items are verified as a count and a bar, a row for each, and the note to the person in its own
+ * highlighted line. A milestone with no items says so, rather than draw an empty bar.
+ */
+function roadmapCards(p, titles) {
+ const milestones = p.milestones || [];
+ if (!milestones.length) return '<div class="card-panel empty">No milestones yet. The coordinator adds one with <code class="inline">pullboard milestone add</code>.</div>';
+ return milestones.map((milestone) => {
+ const rows = milestone.items.map((entry) => milestoneItem(entry, p));
+ const done = rows.filter((row) => row.state === 'verified').length;
+ const name = esc(milestone.name);
+ return '<article class="card-panel milestone"><header><h2>' + name + '</h2>' + (rows.length ? '<span class="milestone-count">' + done + '/' + rows.length + ' done</span>' : '') + '</header>'
+ + (rows.length
+ ? '<svg class="milestone-progress" viewBox="0 0 100 1" preserveAspectRatio="none" role="progressbar" aria-label="' + name + ': ' + done + ' of ' + rows.length + ' done" aria-valuemin="0" aria-valuemax="' + rows.length + '" aria-valuenow="' + done + '"><rect width="' + Math.round((100 * done) / rows.length) + '" height="1"/></svg><ul>' + rows.map((row) => milestoneRow(row, titles)).join('') + '</ul>'
+ : '<p class="milestone-empty">No items yet.</p>')
+ + (milestone.note ? '<p class="milestone-note">' + rich(milestone.note, titles, false) + '</p>' : '') + '</article>';
+ }).join('');
+}
+
+/** Draw the board shown: the sidebar, then every tab's panes from the project's board. */
+function render() {
+ const p = data.project;
+ const group = data.group;
+ renderSide();
+ if (view.answering && view.answering.root !== view.root) answer(null);
+ // Until the first board arrives the page shows no tabs or panes, so a machine with none never
+ // flashes them; with no board to show, one message says how a board starts, in their place.
+ document.body.classList.remove('loading');
+ document.body.classList.toggle('boardless', !p && !group);
+ $('group-view').hidden = !group;
+ $('tabs').hidden = Boolean(group);
+ document.querySelectorAll('[data-pane]').forEach((pane) => { pane.hidden = Boolean(group) || pane.dataset.pane !== view.tab; });
+ $('products').hidden = !p || !p.products.length;
+ if (group) { renderGroup(group); return; }
+ if (!p) return;
+ // Each product's progress (N28): the rows an accepted item cites, and its items by state.
+ $('prod-list').innerHTML = p.products.map((x) => {
+ const states = [['open', '', x.items.open], ['building', 'building', x.items.claimed], ['to verify', 'verify', x.items.submitted], ['verified', 'verified', x.items.verified]].filter(([, , n]) => n);
+ return '<div class="prod" title="' + x.rows + ' rows in force, ' + x.approved + ' approved, ' + x.proven + ' cited by accepted items"><p><b>' + esc(x.name) + '</b><span>' + x.proven + '/' + x.rows + ' rows met</span></p><svg class="bar" viewBox="0 0 100 1" preserveAspectRatio="none" aria-hidden="true"><rect width="' + (x.rows ? Math.round((100 * x.proven) / x.rows) : 0) + '" height="1"/></svg>'
+ + (states.length ? '<small>' + states.map(([label, dot, n]) => '<span><i class="dot ' + dot + '"></i>' + n + ' ' + label + '</span>').join('') + '</small>' : '') + '</div>';
+ }).join('');
+ const items = p.items.filter((i) => i.status !== 'withdrawn');
+ const active = items.filter((i) => stateOf(i) !== 'verified');
+ $('count-items').textContent = active.length || '';
+ $('count-spec').textContent = p.spec.filter((r) => ['pending', 'draft'].includes(r.status)).length || '';
+ $('count-doctrine').textContent = p.practice.filter((r) => ['pending', 'draft'].includes(r.status)).length || '';
+ const titles = new Map(p.items.map((i) => [String(i.id), i.title]));
+ $('roadmap').innerHTML = roadmapCards(p, titles);
+
+ // What needs the person, first, and only the person's calls (B26): the decisions passed up to them,
+ // questions in the spec, held lanes, then draft rows. Work waiting for a verdict or sent back shows
+ // on the board with who holds it; it is the agents' to move.
+ const needs = [
+ ...p.decisions.map((d) => ['decide:' + d.shout_id, d.shout_from, d.shout_text, 'decide', d.shout_at]),
+ ...p.spec.filter((r) => r.status === 'pending').map((r) => ['spec:' + r.id, r.id, r.text, 'answer in SPEC.md']),
+ ...p.holds.map((h) => ['tab:shouts', h.hold_lane, h.hold_reason, 'lane held by ' + h.hold_by]),
+ ];
+ const drafts = p.spec.filter((r) => r.status === 'draft').length;
+ $('needs').hidden = !needs.length && !drafts;
+ $('needs').innerHTML = '<div class="head"><i></i>Needs you</div>' + needs.slice(0, 6).map(([target, ref, text, what, at]) => '<button class="ny" data-go="' + esc(target) + '" type="button"><code>' + esc(ref) + '</code><span>' + rich(text, titles, false) + '</span><em>' + esc(what) + (at ? ', ' + age(at) : '') + ' →</em></button>').join('') + (needs.length > 6 ? '<div class="muted more">and ' + (needs.length - 6) + ' more</div>' : '') + (drafts ? '<button class="ny" data-go="tab:spec" type="button"><code>' + drafts + '</code><span>draft spec rows to approve or drop</span><em>review →</em></button>' : '');
+
+ const lanes = p.lanes;
+ const working = lanes.filter((l) => l !== 'coordinator');
+ // New work goes first to a lane that owns folders, where builders work, then to the coordinator; a
+ // lane that owns none, such as review, is for verifiers and comes last.
+ const filing = [...working.filter((l) => p.owning.includes(l)), 'coordinator', ...working.filter((l) => !p.owning.includes(l))];
+ if ($('add-lane').dataset.lanes !== filing.join()) {
+ $('add-lane').dataset.lanes = filing.join();
+ $('add-lane').innerHTML = filing.map((l) => '<option>' + esc(l) + '</option>').join('');
+ $('hold-lane').innerHTML = working.map((l) => '<option>' + esc(l) + '</option>').join('');
+ }
+ const approved = p.spec.filter((r) => r.status === 'approved');
+ $('add-specs').placeholder = (approved.length ? approved : p.spec).slice(0, 2).map((r) => r.id).join(',') || 'none yet';
+ const q = $('q').value.trim().toLowerCase();
+ // Each chip counts what it would show under the lane and the search. A search looks through every
+ // state, withdrawn items included; browsing leaves those out.
+ const matching = (q ? p.items : items)
+ .filter((i) => !q || ('#' + i.id + ' ' + i.title + ' ' + i.lane + ' ' + i.specs.join(' ') + ' ' + (i.criterion || '')).toLowerCase().includes(q));
+ const inState = (s) => (i) => s === 'all' || (s === 'active' ? !['verified', 'withdrawn'].includes(stateOf(i)) : stateOf(i) === s);
+ const names = { active: 'Active', verified: 'Verified', all: 'All' };
+ $('state-chips').innerHTML = Object.keys(names).map((s) => '<button data-state="' + s + '" class="' + (view.state === s ? 'on' : '') + '" type="button">' + names[s] + '<b>' + matching.filter(inState(s)).length + '</b></button>').join('');
+ const shown = matching.filter(inState(view.state)).sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
+ // With nothing picked, the detail shows the first row, and keeps it when a refresh reorders the list.
+ // While another project loads, the item picked there waits for its own board.
+ if (data.root === view.root && !view.adding && !p.items.some((i) => i.id === view.item)) view.item = shown.length ? shown[0].id : null;
+ const heldLanes = new Map(p.holds.map((h) => [h.hold_lane, h]));
+ $('chain').innerHTML = shown.length ? shown.map((i) => {
+ const s = stateOf(i);
+ const who = s === 'building' ? i.owner : [i.builtBy, i.verifiedBy].filter(Boolean).join(' → ');
+ // What an open item waits on, if anything: items not yet verified, or a hold on its lane.
+ const hold = s === 'open' ? heldLanes.get(i.lane) : null;
+ const waits = s === 'open' && i.blockedBy.length ? i.blockedBy : [];
+ const gated = waits.length > 0 || !!hold;
+ const pills = (waits.length ? '<span class="gate">' + waits.map((id, index) => '<span class="wait-unit">' + (index ? '' : 'waits on ') + '<button class="ref" data-go="item:' + id + '" type="button">#' + id + '</button></span>').join(', ') + '</span>' : '') + (hold ? '<span class="gate">lane held: ' + esc(hold.hold_reason) + '</span>' : '');
+ const tag = s === 'building' && i.owner ? '<span class="chip busy" title="building, held by ' + esc(i.owner) + '">' + esc(i.owner) + '</span>'
+ : s === 'verify' && i.reviewer ? '<span class="chip warn" title="reviewing until ' + esc(when(i.reviewUntil)) + '">' + esc(i.reviewer) + ' reviewing</span>'
+ : s === 'open' ? (gated ? '<span class="chip gate">' + (waits.length ? 'gated' : 'lane held') + '</span>' : '<span class="chip free">unclaimed</span>') : chip(s);
+ return '<li class="row' + (view.item === i.id ? ' on' : '') + (gated ? ' gated' : '') + '" data-item="' + i.id + '"><span class="dot ' + s + '"></span><div><div class="t"><span>#' + i.id + '</span>' + rich(i.title, titles) + '</div><div class="meta"><span>' + esc(i.lane) + '</span>' + (i.specs.length ? '<span>' + esc(i.specs.join(', ')) + '</span>' : '') + (who ? '<span>' + esc(who) + '</span>' : '') + pills + '<span>' + age(i.updatedAt) + '</span>' + (rejected(i) ? '<span class="why">' + esc(i.verdict.reason + ': ' + firstLine(i.verdict.note)) + '</span>' : '') + '</div></div>' + tag + '</li>';
+ }).join('') : '<li class="empty">' + (items.length ? 'No items match.' : snapshot ? 'No items at this event.' : 'No items yet. Add the first one with New item.') + '</li>';
+
+ const item = p.items.find((i) => i.id === view.item);
+ // The form shows when asked for, or when the project has no item at all, withdrawn ones included.
+ const adding = view.adding || !p.items.length;
+ $('add-form').hidden = !adding;
+ $('add-cancel').hidden = !p.items.length;
+ $('detail').hidden = adding;
+ if (!item) $('detail').innerHTML = '<div class="empty">Pick an item to see its criterion, verdicts and history.</div>';
+ if (item && !view.adding) {
+ const s = stateOf(item);
+ const cited = item.specs.map((id) => p.spec.find((r) => r.id === id) || { id, status: 'missing', text: '(not in SPEC.md)' });
+ // Why it came back is the first thing the person reads; the verdicts before it stay below.
+ const back = rejected(item);
+ const earlier = back ? item.verdicts.slice(0, -1) : item.verdicts;
+ $('detail').innerHTML = '<div class="stack"><div><h2><span>#' + item.id + '</span>' + rich(item.title, titles) + '</h2><div class="meta spaced">' + chip(s) + '<span class="chip">' + esc(item.lane) + '</span><span class="chip">' + esc(item.route) + '</span></div></div>'
+ + (back ? '<div class="sentback"><h3>Sent back' + (s === 'building' ? ', being reworked' : s === 'verify' ? ', resubmitted' : s === 'withdrawn' ? ', then withdrawn' : '') + '</h3>' + verdictHtml(item.verdict) + '</div>' : '')
+ + (item.criterion ? '<div><h3>Criterion</h3><div class="text">' + rich(item.criterion, titles) + '</div></div>' : '')
+ + (cited.length ? '<div><h3>Spec rows it serves</h3>' + cited.map((r) => '<div class="rowref"><code>' + esc(r.id) + '</code><div>' + esc(r.text) + ' <span class="chip ' + tone(r.status) + '">' + esc(r.status) + '</span></div></div>').join('') + '</div>' : '')
+ + (item.brief ? '<div><h3>Brief</h3><div class="text muted">' + rich(item.brief, titles) + '</div></div>' : '')
+ + '<div><h3>People and commits</h3><dl class="kv">' + (item.owner && s === 'building' ? '<dt>holding</dt><dd>' + esc(item.owner) + '</dd>' : '') + (item.builtBy ? '<dt>built by</dt><dd>' + esc(item.builtBy) + '</dd>' : '') + (item.verifiedBy ? '<dt>verified by</dt><dd>' + esc(item.verifiedBy) + '</dd>' : '') + (item.commit ? '<dt>commit</dt><dd><code>' + esc(item.commit.slice(0, 12)) + '</code></dd>' : '') + (item.merged ? '<dt>merged</dt><dd><code>' + esc(item.merged.slice(0, 12)) + '</code></dd>' : '') + (item.blockedBy.length ? '<dt>waits on</dt><dd class="waits-on">' + item.blockedBy.map((id) => '<span class="wait-unit"><button class="ref" data-go="item:' + id + '" type="button">#' + id + '</button></span>').join(', ') + '</dd>' : '') + '</dl></div>'
+ + (back && !earlier.length ? '' : '<div><h3>' + (back ? 'Earlier verdicts' : 'Verdicts') + '</h3>' + (earlier.length ? earlier.map(verdictHtml).join('') : '<div class="muted">None yet.</div>') + '</div>')
+ + '<div><h3>History</h3>' + timeline(item) + '</div>'
+ + '<div class="links"><button data-shout="' + esc(item.lane) + '" data-about="' + item.id + '" type="button">Shout the ' + esc(item.lane) + ' lane about #' + item.id + '</button><button data-new type="button">New item</button></div></div>';
+ }
+
+ // Every #id in a shout that names an item opens it, whatever stands next to it. The ids are found in
+ // the raw text and each piece is escaped on its own, so an apostrophe's &#39; is never read as one;
+ // a number that names no item stays text. A path:lines@commit reference opens that code (B23). It
+ // counts only as a whole word, never as the tail of one, so what it opens is what it says, and the
+ // view refuses what is no path in the repo.
+ const mark = (x) => (x.shout_decision ? '<span class="mark ask">decision</span> ' : x.shout_answers ? '<span class="mark">answer</span> ' : '');
+ // Evidence a shout carries (B22), as the fields it is: its kind and outcome, the item, who sent it,
+ // and the commit, shortened, with the full SHA on hover.
+ const evidence = (x) => (x.shout_evidence_kind ? '<span class="ev"><b>' + esc(x.shout_evidence_kind) + '</b> ' + esc(x.shout_evidence_outcome) + ' · ' + linked('#' + x.shout_evidence_item, titles) + ' · ' + esc(x.shout_from) + ' · <code title="' + esc(x.shout_evidence_commit) + '">' + esc(String(x.shout_evidence_commit).slice(0, 12)) + '</code></span>' : '');
+ $('feed').innerHTML = p.shouts.length ? byDay(p.shouts, (x) => x.shout_at, (x) => '<div><time>' + clock(x.shout_at) + '</time><div><b>' + esc(x.shout_from) + ' → ' + esc(x.shout_to) + '</b> ' + mark(x) + rich(x.shout_text, titles) + evidence(x) + '</div></div>') : '<div class="empty">No shouts yet.</div>';
+ // Each ask waits here until it is answered (B21); the answer itself is typed in the form below. The
+ // person answers the ones passed up to them; the rest wait on whoever holds them (B26).
+ $('decisions').hidden = !p.decisions.length && !p.asked.length;
+ $('decisions').innerHTML = (p.decisions.length ? '<div class="head"><i></i>Decision needed</div>' + p.decisions.map((d) => '<div class="ask"><p><small><b>' + esc(d.shout_from) + '</b> asks, ' + age(d.shout_at) + '</small></p><p>' + rich(d.shout_text, titles) + '</p><button class="ghost" data-go="decide:' + d.shout_id + '" type="button">Answer</button></div>').join('') : '')
+ + (p.asked.length ? '<div class="head quiet">Waiting on others</div>' + p.asked.map((d) => '<div class="ask other"><p><small><b>' + esc(d.shout_from) + '</b> asks <b>' + esc(d.shout_to) + '</b>, ' + age(d.shout_at) + '</small></p><p>' + rich(d.shout_text, titles) + '</p></div>').join('') : '');
+ $('shout-targets').innerHTML = ['all', ...lanes, ...p.agents.map((a) => a.agent_id)].map((t) => '<option value="' + esc(t) + '">').join('');
+ // Each agent with what it holds: its claim, then its work sent back, then its work waiting for a
+ // verdict. The worktree path is there on hover; what the person reads is who is doing what.
+ // A review an agent holds (V15) comes right after its claim.
+ const rank = (a, i) => i.status === 'claimed' ? 0 : i.reviewer === a.agent_id ? 1 : stateOf(i) === 'back' ? 2 : 3;
+ const holding = (a) => items.filter((i) => i.status === 'claimed' ? i.owner === a.agent_id : i.reviewer === a.agent_id || (i.builtBy === a.agent_id && ['back', 'verify'].includes(stateOf(i)))).sort((x, y) => rank(a, x) - rank(a, y));
+ $('agents').innerHTML = p.agents.length ? p.agents.map((a) => {
+ const mine = holding(a);
+ return '<div class="agent"><div><b title="' + esc(a.agent_path) + '">' + esc(a.agent_id) + '</b><span class="muted">' + esc(a.agent_lane) + ' · ' + esc(a.agent_route) + '</span>' + (a.lastMoveAt ? '<time data-ago="' + esc(a.lastMoveAt) + '" title="last moved ' + when(a.lastMoveAt) + '">' + ago(a.lastMoveAt) + '</time>' : '') + '</div>'
+ + (mine.length ? mine.map((i) => '<button data-go="item:' + i.id + '" type="button"><span>#' + i.id + ' ' + rich(i.title, titles, false) + '</span>' + (i.reviewer === a.agent_id ? '<span class="chip warn">reviewing</span>' : chip(stateOf(i))) + '</button>').join('') : '<small>idle</small>') + '</div>';
+ }).join('') : '<div class="empty">No agents yet.</div>';
+ const held = new Map(p.holds.map((h) => [h.hold_lane, h]));
+ $('lanes').innerHTML = working.map((l) => '<div class="lane"><span><b>' + esc(l) + '</b> ' + (held.has(l) ? '<span class="chip no">held by ' + esc(held.get(l).hold_by) + '</span> <span class="muted">' + esc(held.get(l).hold_reason) + '</span>' : '<span class="chip ok">open</span>') + '</span>' + (held.has(l) ? '<button class="ghost" data-release="' + esc(l) + '" type="button">Release</button>' : '') + '</div>').join('');
+
+ for (const kind of ['spec', 'doctrine']) {
+ const rows = kind === 'spec' ? p.spec : p.practice;
+ const filter = view.rows[kind];
+ const labels = { decide: 'Needs your decision', all: 'All rows', approved: 'Approved' };
+ const n = { decide: rows.filter((r) => ['pending', 'draft'].includes(r.status)).length, all: rows.length, approved: rows.filter((r) => r.status === 'approved').length };
+ $(kind + '-chips').innerHTML = Object.keys(labels).map((f) => '<button data-rows="' + kind + ':' + f + '" class="' + (filter === f ? 'on' : '') + '" type="button">' + labels[f] + '<b>' + n[f] + '</b></button>').join('');
+ const shownRows = rows.filter((r) => filter === 'all' || (filter === 'decide' ? ['pending', 'draft'].includes(r.status) : r.status === 'approved'));
+ let section = null;
+ $(kind + '-list').innerHTML = shownRows.length ? shownRows.map((r) => {
+ const head = r.section !== section ? '<h4>' + esc(r.section) + '</h4>' : '';
+ section = r.section;
+ const declined = kind === 'doctrine' && r.status === 'wont';
+ const text = declined ? '<s>' + esc(r.standardText || r.text) + '</s>' : esc(r.text);
+ const reason = declined && r.reason ? '<small class="rule-reason">Reason: ' + esc(r.reason) + '</small>' : '';
+ const source = kind === 'doctrine' ? '<small class="rule-source">' + esc(ruleSource(r)) + '</small>' : '';
+ return head + '<div class="srow' + (view.row[kind] === r.id ? ' on' : '') + '" data-row="' + kind + ':' + esc(r.id) + '"><code>' + esc(r.id) + '</code><span><span class="chip ' + tone(r.status) + '">' + esc(r.status) + '</span>' + source + '</span><span>' + text + reason + '</span></div>';
+ }).join('') : '<div class="empty">' + (rows.length ? 'No rows match.' : kind === 'spec' ? 'No spec rows yet. Each requirement is one row in SPEC.md, such as G1 [draft, must] and a line; write them, or ask an agent to, and they show up here.' : 'No practice rows yet: they live in PRACTICE.md.') + '</div>';
+ const row = rows.find((r) => r.id === view.row[kind]);
+ const citing = row ? p.items.filter((i) => i.specs.includes(row.id)) : [];
+ const declined = kind === 'doctrine' && row && row.status === 'wont';
+ const text = row ? declined ? '<s>' + esc(row.standardText || row.text) + '</s>' : esc(row.text) : '';
+ const source = kind === 'doctrine' && row ? '<span class="chip">' + esc(ruleSource(row)) + '</span>' : '';
+ const reason = declined && row.reason ? '<dt>reason</dt><dd>' + esc(row.reason) + '</dd>' : '';
+ const home = kind === 'doctrine' && row && row.origin === 'standard' ? 'Standard rules come with Pullboard; override or decline one in PRACTICE.md.' : 'Rows change in ' + (kind === 'spec' ? 'SPEC.md' : 'PRACTICE.md') + ', and only you approve them.';
+ $(kind + '-detail').innerHTML = row ? '<div class="stack tight"><h2><span>' + esc(row.id) + '</span>' + text + '</h2><div class="meta"><span class="chip ' + tone(row.status) + '">' + esc(row.status) + '</span>' + (row.tier ? '<span class="chip">' + esc(row.tier) + '</span>' : '') + source + '</div><dl class="kv"><dt>section</dt><dd>' + esc(row.section) + '</dd>' + reason + (row.gate ? '<dt>gate</dt><dd>' + esc(row.gate) + '</dd>' : '') + (row.serves && row.serves.length ? '<dt>serves</dt><dd>' + esc(row.serves.join(', ')) + '</dd>' : '') + '</dl><div><h3>Items that cite it</h3>' + (citing.length ? '<div class="links">' + citing.map((i) => '<button data-go="item:' + i.id + '" type="button">#' + i.id + ' ' + rich(i.title, titles, false) + '</button>').join('') + '</div>' : '<div class="muted">None yet.</div>') + '</div><div class="muted">' + home + '</div></div>' : '<div class="empty">Pick a row to see it, and the items that cite it.</div>';
+ }
+
+ if (keep('pb.flow') !== 'hidden') $('flow').innerHTML = flowSvg(p);
+ $('activity').innerHTML = p.events.length ? byDay(p.events, (e) => e.event_at, (e) => '<div><time>' + clock(e.event_at) + '</time><div class="act"><b>' + esc(e.event_by) + '</b> ' + esc(e.event_kind) + (e.item_id ? ' <button class="ref" data-go="item:' + e.item_id + '" type="button">#' + e.item_id + '</button>' + (titles.has(String(e.item_id)) ? ' <span class="what">' + esc(titles.get(String(e.item_id))) + '</span>' : '') : '') + '</div></div>') : '<div class="empty">No activity yet.</div>';
+ showTab();
+}
+
+/**
+ * Show or hide the lifecycle on Activity, and keep the choice: a person who closed it has learned
+ * it, so it stays closed across reloads, and across restarts of the view, which serves from the
+ * same address again, until they open it. While hidden it is not drawn.
+ */
+function showFlow(shown) {
+ keep('pb.flow', shown ? 'shown' : 'hidden');
+ $('flow-panel').hidden = !shown;
+ $('flow-show').hidden = shown;
+ if (shown && data && data.project) $('flow').innerHTML = flowSvg(data.project);
+}
+
+function showTab() {
+ document.querySelectorAll('[data-pane]').forEach((pane) => { pane.hidden = pane.dataset.pane !== view.tab; });
+ document.querySelectorAll('.tab').forEach((button) => button.classList.toggle('on', button.dataset.tab === view.tab));
+ countUnseen();
+}
+
+/** The address that names a tab: the Roadmap's own, or the board's, keeping the rest as it is. */
+function tabHref(tab) {
+ const own = tab === 'roadmap';
+ return routed ? (own ? '/roadmap' : '/') + location.search : location.pathname + location.search + (own ? '#roadmap' : '');
+}
+
+/**
+ * Keep the address naming what the page shows (N38). Moving between the Roadmap and another tab
+ * changes it and adds a history entry, so Back and Forward return there; anything else, or push
+ * false, only updates the entry. Each entry carries its project and item too, so returning to one
+ * shows that board as it was. A host that refuses the change still shows the tab.
+ */
+function address(push = true) {
+ if (typeof history === 'undefined' || typeof location === 'undefined') return;
+ const state = { tab: view.tab, root: view.root, item: view.item };
+ const href = tabHref(view.tab);
+ try {
+ if (push && href !== location.pathname + location.search + (routed ? '' : location.hash)) history.pushState(state, '', href);
+ else history.replaceState(state, '');
+ } catch { /* The tab shows all the same. */ }
+}
+
+/**
+ * Show what a history entry names, on Back, Forward or an edited #roadmap: the tab its address
+ * names, or at the board's address the tab the entry kept, and the project and item it kept.
+ */
+function fromAddress(event) {
+ const kept = (event && event.state) || {};
+ view.tab = addressTab() || (kept.tab && kept.tab !== 'roadmap' ? kept.tab : homeTab());
+ if (view.tab !== 'roadmap') keep('pb.tab', view.tab);
+ const item = typeof kept.item === 'number' ? kept.item : null;
+ if (kept.root && kept.root !== view.root && data && data.projects.some((x) => x.ok && x.root === kept.root)) return switchTo(kept.root, item, false);
+ if (item !== null && view.tab === 'items') view.item = item;
+ address(false);
+ if (data) render();
+ else showTab();
+}
+
+/** Pick a tab. The board's address keeps it for next time; the Roadmap has an address of its own. */
+function openTab(tab) {
+ view.tab = tab;
+ if (tab !== 'roadmap') keep('pb.tab', tab);
+ address();
+}
+
+/**
+ * Count on the Shouts tab the shouts that came after the newest one the person has seen in this
+ * project. Seeing means having the Shouts tab open with the board drawn; a project shown for the
+ * first time has seen everything so far. The mark is kept in this browser, so a reload counts
+ * nothing old. The board counts the shouts since the mark the last refresh sent, so a burst larger
+ * than the forty loaded still counts in full; until a moved mark reaches the board, the loaded
+ * shouts count, which is exact then since the mark only ever moves to the newest.
+ */
+function countUnseen() {
+ const p = data && data.project;
+ // While a switch loads, the board on hand is the last project's: it marks nothing for this one.
+ if (!p || data.root !== view.root) return;
+ const key = 'pb.seen.' + view.root;
+ const kept = view.seen[key] ?? keep(key);
+ const newest = p.shouts.length ? p.shouts[0].shout_id : 0;
+ const seen = view.tab === 'shouts' || kept === null || kept === undefined ? newest : Number(kept);
+ if (String(seen) !== String(kept)) { view.seen[key] = seen; keep(key, String(seen)); }
+ $('count-shouts').textContent = (p.unseen && p.unseen.since === seen ? p.unseen.count : p.shouts.filter((x) => x.shout_id > seen).length) || '';
+}
+
+/**
+ * Put the shout form in answer mode for an open decision (B21), or back to a plain shout with null.
+ * The form is never redrawn, so what the person types survives every refresh; only its answer line,
+ * its To and its button change. The To the person had comes back when the answer is done. An answer
+ * belongs to the project whose question it shows: leaving that project leaves answer mode.
+ */
+function answer(id) {
+ const ask = id === null ? null : data.project.decisions.find((d) => d.shout_id === id) || null;
+ if (ask && !view.answering) view.to = $('shout-to').value;
+ if (!ask && view.answering) $('shout-to').value = view.to || '';
+ view.answering = ask ? { root: view.root, id: ask.shout_id } : null;
+ $('answering').hidden = !ask;
+ $('answering-who').textContent = ask ? ask.shout_from : '';
+ $('answering-q').textContent = ask ? ask.shout_text : '';
+ if (ask) $('shout-to').value = ask.shout_from;
+ $('shout-to').disabled = Boolean(ask);
+ $('shout-send').textContent = ask ? 'Answer' : 'Shout';
+ if (ask) $('shout-text').focus();
+}
+
+/**
+ * Follow a link in the page: an item, a spec row, a tab or a decision to answer. An item can live on
+ * another project's board, root, which the page then switches to.
+ */
+function go(target, root = view.root) {
+ const [kind, id] = target.split(':');
+ let tab = view.tab;
+ if (kind === 'item') { tab = 'items'; view.state = 'all'; view.before = null; }
+ else if (kind === 'spec') { tab = 'spec'; view.row.spec = id; view.rows.spec = 'all'; }
+ else if (kind === 'tab') tab = id;
+ else if (kind === 'decide') { tab = 'shouts'; answer(Number(id)); }
+ openTab(tab);
+ if (kind === 'item') pick(Number(id), root);
+ else render();
+}
+
+/** Show an item's detail, on another project's board when root names one. */
+function pick(id, root = view.root) {
+ view.adding = false;
+ if (root !== view.root) return switchTo(root, id);
+ view.item = id;
+ address(false);
+ render();
+ reveal();
+}
+
+/** Where the list and the detail stack (under 900px), bring the detail into view. */
+function reveal() {
+ if (matchMedia('(max-width: 900px)').matches) $('detail').scrollIntoView({ block: 'start', behavior: 'smooth' });
+}
+
+/**
+ * A search looks through every state. Each keystroke with text in the box selects All, even after a
+ * chip was clicked mid-search; emptying the box brings back the chip from before the search began.
+ */
+function search() {
+ if ($('q').value.trim()) {
+ if (view.before == null) view.before = view.state;
+ view.state = 'all';
+ } else if (view.before != null) {
+ view.state = view.before;
+ view.before = null;
+ }
+ render();
+}
+
+/**
+ * Open or close the code a path:lines@commit reference names (B23). The first open asks the view for
+ * those lines as they were at that commit; the answer stays with the page, so every refresh redraws
+ * it, and a failed ask is tried again on the next open.
+ */
+async function code(ref, before) {
+ const c = (view.code[view.root + '\n' + before + '\n' + ref] ??= { open: false });
+ c.open = !c.open;
+ render();
+ if (!c.open || c.lines) return;
+ c.error = null;
+ try {
+ const reply = await api(boardPath(view.root) + '/code?ref=' + encodeURIComponent(ref) + '&before=' + encodeURIComponent(before));
+ Object.assign(c, reply.code);
+ } catch (error) {
+ c.error = String(error.message || error);
+ }
+ render();
+}
+
+/** Translate the page's five actions into the public move shape and a familiar command label. */
+function pageMove(command, args = {}) {
+ /** Trim form values before constructing the move and its display label. */
+ const text = (value) => String(value || '').trim();
+ if (command === 'add') {
+ const fields = { lane: text(args.lane), title: text(args.title) };
+ const label = ['add', fields.lane, fields.title];
+ for (const name of ['criterion', 'specs', 'brief']) if (text(args[name])) { fields[name] = text(args[name]); label.push('--' + name, fields[name]); }
+ return { body: { verb: 'add', args: fields }, label: label.join(' ') };
+ }
+ if (command === 'shout') return { body: { verb: 'shout', args: { to: text(args.to), text: text(args.text) } }, label: ['shout', text(args.to), text(args.text)].join(' ') };
+ if (command === 'answer') return { body: { verb: 'answer', item: Number(args.id), args: { text: text(args.text), as: 'person' } }, label: ['answer', text(args.id), text(args.text), '--as', 'person'].join(' ') };
+ if (command === 'hold') return { body: { verb: 'hold', args: { lane: text(args.lane), reason: text(args.reason) } }, label: ['hold', text(args.lane), '--reason', text(args.reason)].join(' ') };
+ if (command === 'release') return { body: { verb: 'hold', args: { lane: text(args.lane), off: true } }, label: ['hold', text(args.lane), '--off'].join(' ') };
+ throw new Error('No view action ' + String(command) + '; choose add, shout, answer, hold or release.');
+}
+
+/** Describe an API-confirmed move without exposing its transport document in the page. */
+function moveMessage(move, result) {
+ if (move.verb === 'add') return 'added #' + result.item.item_id;
+ if (move.verb === 'shout') return 'shouted to ' + move.args.to;
+ if (move.verb === 'answer') return 'answered #' + move.item;
+ return move.args.off ? 'released the ' + move.args.lane + ' lane' : 'holding the ' + move.args.lane + ' lane: ' + move.args.reason;
+}
+
+/** Run a public API move beside its action and let only the latest one own the console and timer. */
+async function act(command, args, anchor) {
+ const out = $('console');
+ if (snapshot || readOnly) { out.hidden = false; out.className = 'console no'; out.textContent = snapshot ? 'This is a read-only snapshot.' : 'This is a read-only view.'; return false; }
+ if (anchor) {
+ const target = anchor.matches('form')
+ ? anchor.querySelector('.actions') || anchor.querySelector('[type="submit"]') || anchor
+ : anchor.closest('#lanes') || anchor;
+ target.insertAdjacentElement(anchor.matches('form') ? 'beforebegin' : 'afterend', out);
+ }
+ const run = (view.acting = (view.acting || 0) + 1);
+ const latest = () => run === view.acting;
+ clearTimeout(view.closing);
+ out.hidden = false;
+ out.className = 'console';
+ out.textContent = 'running…';
+ out.scrollIntoView({ block: 'nearest' });
+ try {
+ const move = pageMove(command, args);
+ const result = await api(boardPath(view.root) + '/moves', move.body);
+ if (latest()) {
+ out.className = 'console ok';
+ out.textContent = '$ pullboard ' + move.label + '\n' + moveMessage(move.body, result.result);
+ out.scrollIntoView({ block: 'center' });
+ // What went through says so and then steps aside; a refusal stays until the person closes it.
+ view.closing = setTimeout(() => { if (latest()) out.hidden = true; }, 6000);
+ }
+ await refresh();
+ if (latest()) out.scrollIntoView({ block: 'center' });
+ return true;
+ } catch (error) {
+ if (latest()) {
+ out.className = 'console no';
+ out.textContent = String(error.message || error);
+ out.scrollIntoView({ block: 'center' });
+ }
+ return false;
+ }
+}
+
+/**
+ * Move every age on the page on to now, where it stands. A list is rebuilt only when the board
+ * changes, so a click is never lost to a rebuild; on a quiet board the ages would otherwise stay
+ * as old as the page.
+ */
+function tickAges() {
+ document.querySelectorAll('[data-ago]').forEach((node) => { node.textContent = ago(node.dataset.ago); });
+}
+
+/** Open or close the project list where the sidebar is folded into a top bar (under 900px). */
+function fold(open) {
+ $('side').classList.toggle('open', open);
+ $('proj-switch').setAttribute('aria-expanded', String(open));
+}
+
+/**
+ * Show another project: mark it at once, dim the old one's panes until its board arrives. Given an
+ * item, its board opens on that item; with record false the history entry stays as it is, for a
+ * move that came from the entry.
+ */
+function switchTo(root, item = null, record = true) {
+ answer(null);
+ view.root = root;
+ view.item = item;
+ view.adding = false;
+ keep('pb.project', root);
+ if (record) address(false);
+ fold(false);
+ // The board that arrives is drawn even if it matches the last one seen, so the pick is made from it.
+ seen = '';
+ if (data) renderSide();
+ document.body.classList.add('switching');
+ refresh().catch(() => { $('live').textContent = 'offline: is pullboard view still running?'; }).finally(() => {
+ document.body.classList.remove('switching');
+ if (item !== null && view.root === root && view.tab === 'items') reveal();
+ });
+}
+
+document.addEventListener('click', (event) => {
+ const t = event.target.closest('[data-root],[data-tab],[data-go],[data-item],[data-state],[data-rows],[data-row],[data-release],[data-shout],[data-new],[data-code],#proj-switch,#console');
+ if (!event.target.closest('.side')) fold(false);
+ if (!t) return;
+ if (t.id === 'proj-switch') { fold(!$('side').classList.contains('open')); return; }
+ if (t.id === 'console') { t.hidden = true; return; }
+ if (t.dataset.root) switchTo(t.dataset.root);
+ else if (t.dataset.tab) { openTab(t.dataset.tab); showTab(); }
+ else if (t.dataset.go) go(t.dataset.go, t.dataset.board);
+ else if (t.dataset.item) pick(Number(t.dataset.item));
+ else if (t.dataset.state) { view.state = t.dataset.state; render(); }
+ else if (t.dataset.rows) { const [kind, f] = t.dataset.rows.split(':'); view.rows[kind] = f; render(); }
+ else if (t.dataset.row) { const [kind, id] = t.dataset.row.split(':'); view.row[kind] = id; render(); }
+ else if (t.dataset.code) code(t.dataset.code, t.dataset.before || '');
+ else if (t.dataset.release) act('release', { lane: t.dataset.release }, t);
+ else if (t.dataset.shout) { answer(null); $('shout-to').value = t.dataset.shout; $('shout-text').value = '#' + t.dataset.about + ': '; openTab('shouts'); showTab(); $('shout-text').focus(); }
+ else if (t.dataset.new !== undefined) { view.adding = true; render(); $('add-title').focus(); }
+});
+// The form covers the picked item rather than dropping it, so Cancel brings it back.
+$('new-item').addEventListener('click', () => { view.adding = true; render(); $('add-title').focus(); });
+$('add-cancel').addEventListener('click', () => { view.adding = false; render(); });
+$('answer-cancel').addEventListener('click', () => answer(null));
+$('flow-hide').addEventListener('click', () => showFlow(false));
+$('flow-show').addEventListener('click', () => showFlow(true));
+$('flow-panel').hidden = keep('pb.flow') === 'hidden';
+$('flow-show').hidden = !$('flow-panel').hidden;
+// Each press moves on one, from the system's theme to light, then dark, and back; this browser keeps it.
+$('theme').addEventListener('click', () => {
+ const next = { light: 'dark', dark: 'system' }[document.documentElement.dataset.theme] || 'light';
+ keep('pb.theme', next);
+ theme(next);
+});
+$('q').addEventListener('input', search);
+$('add-form').addEventListener('submit', async (event) => {
+ event.preventDefault();
+ if (await act('add', { lane: $('add-lane').value, title: $('add-title').value, criterion: $('add-criterion').value, specs: $('add-specs').value, brief: $('add-brief').value }, event.currentTarget)) {
+ $('add-title').value = '';
+ $('add-criterion').value = '';
+ $('add-specs').value = '';
+ $('add-brief').value = '';
+ }
+});
+$('shout-form').addEventListener('submit', async (event) => {
+ event.preventDefault();
+ const text = $('shout-text').value;
+ const ask = view.answering;
+ if (ask && ask.root !== view.root) return answer(null);
+ if (!(await (ask ? act('answer', { id: ask.id, text }, event.currentTarget) : act('shout', { to: $('shout-to').value, text }, event.currentTarget)))) return;
+ $('shout-text').value = '';
+ answer(null);
+});
+$('hold-form').addEventListener('submit', async (event) => {
+ event.preventDefault();
+ if (await act('hold', { lane: $('hold-lane').value, reason: $('hold-reason').value }, event.currentTarget)) $('hold-reason').value = '';
+});
+// The first entry keeps the tab it opened on; Back and Forward show what each entry names.
+address(false);
+globalThis.addEventListener?.('popstate', fromAddress);
+showTab();
+if (snapshot) {
+ $('replay-play').addEventListener('click', playReplay);
+ $('replay-pause').addEventListener('click', pauseReplay);
+ $('replay-speed').addEventListener('change', () => {
+ if (snapshotReplay.playing) { clearTimeout(snapshotReplay.timer); snapshotReplay.timer = setTimeout(advanceReplay, 1000 / Number($('replay-speed').value)); }
+ });
+}
+/** Load an explicitly configured transport before the first read; its updates refresh this page. */
+async function startPage() {
+ if (transportModule) {
+ const module = await import(transportModule);
+ if (typeof module.createTransport !== 'function') throw new Error('The browser transport must export createTransport({ onUpdate }).');
+ transport = await module.createTransport({ onUpdate: () => transport ? refresh().catch((error) => { $('live').textContent = 'offline: ' + error.message; }) : Promise.resolve() });
+ if (!transport || typeof transport.request !== 'function') throw new Error('The browser transport must provide request(path, body).');
+ }
+ await refresh();
+}
+startPage().catch((error) => { document.body.classList.remove('loading'); $('live').textContent = 'cannot reach the view: ' + error.message; });
+if (!snapshot) setInterval(() => { if (!document.hidden) refresh().catch(() => { $('live').textContent = 'offline: is pullboard view still running?'; }); }, 3000);
+setInterval(tickAges, 60000);
+</script>
+</body>
+</html>
\ No newline at end of file
diff --git a/docs/demo/view.css b/docs/demo/view.css
new file mode 100644
index 00000000..f434b7ac
--- /dev/null
+++ b/docs/demo/view.css
@@ -0,0 +1,315 @@
+/*
+ * The styles of `pullboard view` (N26), served at /view.css behind the view's secret. Every colour is
+ * a token holding a light and a dark value; the theme button only picks which one the page shows.
+ */
+:root {
+ color-scheme: light dark;
+ --ground: light-dark(#e9eceb, #0c110f); --surface: light-dark(#fdfefd, #121815); --surface-2: light-dark(#f2f4f1, #171f1b); --line: light-dark(#d3d9d5, #232e29); --line-strong: light-dark(#bcc5bf, #34423b);
+ --ink: light-dark(#121a17, #e7ece9); --ink-muted: light-dark(#4c5852, #9caba3); --ink-faint: light-dark(#7a887f, #6a776f);
+ --accent: light-dark(#08915f, #34d89e); --accent-strong: light-dark(#067049, #4ee3ac); --accent-soft: light-dark(#dcefe6, #10231c); --on-accent: light-dark(#f4fbf7, #05201a);
+ --warn: light-dark(#a2660f, #e4b25a); --warn-soft: light-dark(#f2e6cf, #241d10); --reject: light-dark(#bd4437, #f0776b); --reject-soft: light-dark(#f4e0dc, #271613);
+ --blue: light-dark(#3f6f9e, #6ba7d6); --blue-soft: light-dark(#e1eaf3, #142231); --violet: light-dark(#6b4fc8, #ab9cf2); --violet-soft: light-dark(#ebe6fa, #1e1934);
+ --shade: light-dark(rgba(18,26,23,.05), rgba(0,0,0,.4)); --shade-far: light-dark(rgba(18,26,23,.28), rgba(0,0,0,.7));
+ --shadow: 0 1px 2px var(--shade), 0 12px 34px -18px var(--shade-far);
+ --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
+ --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
+ --top: 56px; --side-w: 236px; --agents-w: clamp(240px, 30%, 306px);
+}
+:root[data-theme="light"] { color-scheme: light; }
+:root[data-theme="dark"] { color-scheme: dark; }
+@media (max-width: 1100px) { :root { --side-w: 208px; } }
+* { box-sizing: border-box; }
+body { margin: 0; background: var(--ground); color: var(--ink); font: 14px/1.5 var(--sans); }
+button, input, select, textarea { font: inherit; color: inherit; }
+[hidden] { display: none !important; }
+:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
+
+.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
+.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 0 10px 16px; background: var(--surface); border-right: 1px solid var(--line); }
+.side-top { display: flex; align-items: center; gap: 10px; height: var(--top); margin: 0 -10px 6px; padding: 0 16px; border-bottom: 1px solid var(--line); }
+.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; white-space: nowrap; }
+.brand svg { width: 22px; height: 22px; flex: none; }
+.switch-btn { display: none; align-items: center; gap: 8px; min-width: 0; border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-weight: 600; }
+.switch-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.switch-btn small { color: var(--ink-faint); font-weight: 400; }
+.theme-btn { flex: none; margin-left: auto; display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 8px; background: none; color: var(--ink-faint); cursor: pointer; }
+.theme-btn:hover { color: var(--ink); background: var(--surface-2); }
+.theme-btn svg { display: none; width: 16px; height: 16px; }
+:root:not([data-theme]) .theme-btn .sys, :root[data-theme="light"] .theme-btn .sun, :root[data-theme="dark"] .theme-btn .moon { display: block; }
+.side-body { display: grid; gap: 2px; align-content: start; }
+.label { font: 600 11px/1 var(--mono); letter-spacing: .07em; text-transform: uppercase; color: var(--ink-faint); padding: 8px 8px 6px; }
+.proj { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1px 8px; align-items: center; width: 100%; text-align: left; border: 1px solid transparent; background: none; border-radius: 8px; padding: 7px 8px; cursor: pointer; }
+.proj:hover { background: var(--surface-2); }
+.proj.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
+.proj .pname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.proj small { grid-column: 1 / -1; color: var(--ink-faint); font-size: 12px; line-height: 1.35; overflow-wrap: anywhere; }
+.repo-group { display: grid; gap: 1px; }
+.project-pick { background: var(--surface-2); }
+.repos { display: grid; gap: 1px; margin-left: 8px; padding-left: 7px; border-left: 1px solid var(--line); }
+.repo-error { margin: 3px 0 5px 8px; padding: 6px 8px; color: var(--ink-faint); font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
+.repo-error b { color: var(--ink-muted); }
+.group-view { display: grid; gap: 14px; max-width: 1000px; }
+.group-panel { padding: 14px 16px; }
+.group-panel h2 { margin: 0 0 10px; font-size: 17px; }
+.group-need { display: grid; grid-template-columns: minmax(90px, auto) auto minmax(0, 1fr) auto; align-items: baseline; gap: 5px 10px; width: 100%; padding: 9px 0; text-align: left; border: 0; border-top: 1px solid var(--line); background: none; cursor: pointer; }
+.group-need:hover { background: var(--surface-2); }
+.group-need > b { color: var(--ink-muted); }
+.group-need > code { color: var(--accent-strong); }
+.group-need > span { overflow-wrap: anywhere; }
+.group-need > em { color: var(--ink-faint); font-size: 12px; font-style: normal; }
+.repo-label { color: var(--ink-muted); }
+.need { min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); font: 700 11.5px/1.5 var(--mono); text-align: center; }
+.products { padding-top: 6px; }
+.prod { display: grid; grid-template-columns: minmax(0, 1fr); gap: 5px; padding: 6px 8px 8px; font-size: 13px; }
+.prod p { margin: 0; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
+.prod p b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.prod p span { color: var(--ink-faint); font: 11.5px var(--mono); white-space: nowrap; }
+.prod .bar { display: block; width: 100%; height: 6px; border-radius: 99px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
+.prod .bar rect { fill: var(--accent); }
+.prod small { display: flex; flex-wrap: wrap; gap: 2px 10px; color: var(--ink-muted); font-size: 12px; }
+.prod small span { display: inline-flex; align-items: center; gap: 5px; }
+.prod small .dot { display: inline-block; width: 7px; height: 7px; }
+.body { min-width: 0; }
+.top { position: sticky; top: 0; z-index: 10; min-height: var(--top); display: flex; align-items: stretch; gap: 12px; padding: 0 18px; background: var(--surface); border-bottom: 1px solid var(--line); }
+.tabs { display: flex; flex-wrap: wrap; gap: 2px; }
+.tab { border: 0; background: none; padding: 6px 10px; border-radius: 6px; align-self: center; cursor: pointer; color: var(--ink-muted); white-space: nowrap; }
+.tab:hover { color: var(--ink); }
+.tab.on { color: var(--ink); background: var(--surface-2); font-weight: 600; }
+.tab b { font: 600 11px var(--mono); color: var(--ink-faint); margin-left: 4px; }
+.live { margin-left: auto; align-self: center; font-size: 12px; color: var(--ink-faint); white-space: nowrap; }
+.switching main, .switching .products { opacity: .45; transition: opacity .12s; }
+
+main { padding: 16px 18px 28px; }
+.first { display: none; max-width: 520px; margin: 10vh auto 0; padding: 22px 24px; }
+.first h2 { margin: 0 0 6px; font-size: 18px; }
+.first p { margin: 0; color: var(--ink-muted); }
+.first code { font: 600 13px var(--mono); color: var(--ink); }
+.boardless .first { display: block; }
+.loading .top, .loading [data-pane], .boardless .top, .boardless [data-pane] { display: none; }
+.two { display: grid; grid-template-columns: minmax(0, 1fr) clamp(300px, 42%, 600px); gap: 16px; align-items: start; }
+.two.narrow { grid-template-columns: minmax(0, 1fr) var(--agents-w); }
+.roadmap { display: grid; gap: 12px; max-width: 900px; align-content: start; }
+.milestone { padding: 14px 16px 12px; }
+.milestone header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
+.milestone h2 { margin: 0; font-size: 17px; line-height: 1.3; overflow-wrap: anywhere; }
+.milestone-count { color: var(--ink-muted); font: 12px var(--mono); white-space: nowrap; }
+.milestone-progress { display: block; width: 100%; height: 7px; margin: 10px 0 6px; overflow: hidden; border-radius: 99px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
+.milestone-progress rect { fill: var(--accent); }
+.milestone ul { display: grid; gap: 2px; margin: 0 -9px; padding: 0; list-style: none; }
+.milestone-item { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; min-height: 44px; padding: 0 9px; border: 1px solid transparent; border-radius: 10px; background: none; text-align: left; }
+button.milestone-item { cursor: pointer; }
+button.milestone-item:hover { background: var(--surface-2); }
+.milestone-item .t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.milestone-item .t code { white-space: nowrap; }
+.milestone-item .id { margin-right: 6px; color: var(--ink-faint); font: 500 12px var(--mono); }
+.milestone-empty { margin: 8px 0 0; color: var(--ink-faint); }
+.milestone-note { margin: 10px 0 2px; padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); color: var(--ink-muted); overflow-wrap: anywhere; }
+@media (max-width: 900px) {
+ .shell { display: block; }
+ .side { position: static; height: auto; overflow: visible; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
+ .side-top { height: auto; margin: 0; padding: 0; border: 0; }
+ .brand span { display: none; }
+ .switch-btn { display: flex; }
+ .side-body { display: none; padding-top: 6px; }
+ .side.open .side-body { display: grid; }
+ .top { padding: 0 6px; }
+ .tab { padding: 6px; }
+ .live { display: none; }
+ main { padding: 12px 10px 24px; }
+ .two, .two.narrow { grid-template-columns: minmax(0, 1fr); }
+ .group-need { grid-template-columns: minmax(80px, auto) auto minmax(0, 1fr); }
+ .group-need > em { grid-column: 3; }
+}
+@media (width < 480px) {
+ .group-need { grid-template-columns: minmax(0, 1fr) auto; gap: 3px 8px; }
+ .group-need > b { grid-column: 1; }
+ .group-need > code { grid-column: 2; }
+ .group-need > span, .group-need > em { grid-column: 1 / -1; }
+ .tabs { flex: 1; display: grid; grid-auto-flow: column; grid-auto-columns: auto; gap: 0; }
+ .tab { display: grid; grid-template-rows: auto 13px; justify-items: center; align-content: center; padding: 7px 2px 5px; font-size: 13.5px; }
+ .tab b { margin: 0; line-height: 13px; }
+}
+.primary { display: grid; gap: 12px; min-width: 0; }
+.card-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); min-width: 0; }
+.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; }
+.toolbar input { flex: 1 1 96px; }
+input, select, textarea { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 8px; padding: 7px 9px; min-width: 0; }
+input:disabled { background: var(--surface-2); color: var(--ink-muted); }
+.go { border: 0; background: var(--ink); color: var(--surface); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; white-space: nowrap; }
+.go:hover { background: var(--accent-strong); color: var(--on-accent); }
+.ghost { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 8px; padding: 5px 10px; cursor: pointer; }
+
+.needs-you { background: color-mix(in srgb, var(--warn) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 38%, var(--line)); border-radius: 14px; box-shadow: var(--shadow); padding: 10px 12px; display: grid; gap: 4px; }
+.needs-you .head { font-weight: 700; display: flex; gap: 8px; align-items: center; }
+.needs-you .head i { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); display: inline-block; }
+.needs-you .head.quiet { color: var(--ink-muted); font-weight: 600; }
+.needs-you .ask + .head.quiet { margin-top: 12px; }
+.needs-you .more { padding: 2px 4px; }
+.ny { display: grid; grid-template-columns: auto minmax(5em, 1fr) minmax(0, max-content); gap: 10px; align-items: baseline; text-align: left; border: 0; background: none; padding: 6px 4px; border-radius: 8px; cursor: pointer; width: 100%; }
+.ny:hover { background: color-mix(in srgb, var(--warn) 10%, var(--surface)); }
+.ny code { font: 600 12px var(--mono); }
+.ny span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-muted); }
+.ny em { font-style: normal; color: var(--warn); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
+@media (width < 480px) { .ny { grid-template-columns: auto minmax(0, 1fr); row-gap: 1px; } .ny em { grid-column: 2; } }
+.ask { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; padding: 6px 4px; }
+.ask > p { grid-column: 1; margin: 0; overflow-wrap: anywhere; }
+.ask small { color: var(--ink-muted); }
+.ask button { grid-row: 1 / span 2; grid-column: 2; }
+.answering { flex: 1 1 100%; display: flex; gap: 10px; align-items: baseline; justify-content: space-between; margin: 0; font-size: 13px; color: var(--ink-muted); }
+.answering > span { min-width: 0; overflow-wrap: anywhere; }
+.mark { font: 600 11px var(--mono); padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--ink-muted); }
+.mark.ask { display: inline; background: var(--warn-soft); color: var(--warn); }
+.ev { display: flex; flex-wrap: wrap; gap: 0 6px; align-items: baseline; width: fit-content; max-width: 100%; margin-top: 4px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); font-size: 12px; color: var(--ink-muted); }
+.ev b { font: 600 11px var(--mono); letter-spacing: .04em; text-transform: uppercase; color: var(--ink); }
+.ev code { font: 12px var(--mono); }
+
+.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 2px; }
+.chips button { flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 9px; cursor: pointer; font-size: 13px; }
+.chips button.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
+.chips button b { font: 600 11px var(--mono); color: var(--ink-faint); margin-left: 4px; }
+.seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 8px; background: var(--surface-2); box-shadow: 0 0 0 1px var(--line); }
+.seg button { border: 0; background: none; padding: 4px 8px; border-radius: 6px; color: var(--ink-muted); cursor: pointer; font-size: 12.5px; white-space: nowrap; }
+.seg button:hover { color: var(--ink); }
+.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(18, 26, 23, .08); }
+.seg button b { font: 600 11px var(--mono); color: var(--ink-faint); margin-left: 5px; }
+
+.chain { list-style: none; margin: 0; padding: 6px; display: grid; gap: 2px; }
+.row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 9px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; }
+.row:hover { background: var(--surface-2); }
+.row.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
+.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
+.dot.building { background: var(--blue); } .dot.verify { background: var(--warn); } .dot.back { background: var(--reject); } .dot.verified { background: var(--accent); }
+.row .t { font-weight: 600; overflow-wrap: anywhere; }
+.row .t span { color: var(--ink-faint); font: 500 12px var(--mono); margin-right: 5px; }
+.meta { display: flex; flex-wrap: wrap; gap: 4px 8px; color: var(--ink-muted); font-size: 12px; margin-top: 2px; }
+.chip { font: 600 10.5px/1 var(--mono); letter-spacing: .03em; padding: 4px 6px; border-radius: 5px; background: var(--surface-2); color: var(--ink-muted); white-space: nowrap; }
+.chip.ok { background: var(--accent-soft); color: var(--accent-strong); }
+.chip.warn { background: var(--warn-soft); color: var(--warn); }
+.chip.no { background: var(--reject-soft); color: var(--reject); }
+.chip.busy { background: var(--blue-soft); color: var(--blue); }
+.chip.free { background: var(--violet-soft); color: var(--violet); }
+.chip.gate { background: none; color: var(--ink-muted); outline: 1px dashed var(--line-strong); outline-offset: -1px; }
+.row.gated { border-color: color-mix(in srgb, var(--reject) 40%, var(--line)); }
+.meta .gate { padding: 0 7px; border-radius: 999px; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--reject) 35%, var(--line)); }
+.meta .gate .wait-unit, .kv dd.waits-on .wait-unit { white-space: nowrap; }
+.meta .gate button.ref { min-height: 0; }
+.meta button.ref { border: 0; background: none; padding: 0; font: inherit; color: var(--accent-strong); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
+.empty { color: var(--ink-faint); padding: 14px 10px; }
+
+.stack { display: grid; gap: 14px; }
+.stack.tight { gap: 12px; }
+.meta.spaced { margin-top: 6px; }
+.detail { position: sticky; top: calc(var(--top) + 16px); max-height: calc(100vh - var(--top) - 32px); overflow-y: auto; padding: 16px; display: grid; gap: 14px; align-content: start; }
+@media (max-width: 900px) { .detail { position: static; max-height: none; } #detail { scroll-margin-top: 60px; } }
+.detail h2 { margin: 0; font-size: 18px; line-height: 1.3; overflow-wrap: anywhere; }
+.detail h2 span { color: var(--ink-faint); font: 600 13px var(--mono); margin-right: 6px; }
+.detail h3 { margin: 0 0 6px; font: 600 11px/1 var(--mono); letter-spacing: .07em; text-transform: uppercase; color: var(--ink-faint); }
+.detail .text { white-space: pre-wrap; overflow-wrap: anywhere; }
+.detail .muted, .muted { color: var(--ink-muted); }
+.kv { display: grid; grid-template-columns: 6.5em minmax(0, 1fr); gap: 4px 10px; font-size: 13px; margin: 0; }
+.kv dt { color: var(--ink-faint); } .kv dd { margin: 0; overflow-wrap: anywhere; }
+.kv dd.waits-on button.ref { border: 0; background: none; padding: 0; font: inherit; color: var(--accent-strong); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
+.kv dd.waits-on button.ref { min-height: 0; }
+.kv code, .detail code { font: 12px var(--mono); }
+.verdict { display: grid; gap: 3px; margin-bottom: 10px; }
+.verdict.yes b { color: var(--accent-strong); } .verdict.no b { color: var(--reject); }
+.verdict .by { font-size: 12px; color: var(--ink-faint); }
+.verdict .note { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
+.sentback { border: 1px solid color-mix(in srgb, var(--reject) 40%, var(--line)); background: color-mix(in srgb, var(--reject) 6%, var(--surface)); border-radius: 10px; padding: 10px 12px; }
+.sentback h3 { color: var(--reject); }
+.sentback .verdict { margin: 0; }
+.meta .why { flex-basis: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--reject); }
+.tl { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
+.tl li { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 10px; padding: 0 0 12px 20px; --c: var(--line-strong); }
+.tl li::before { content: ''; position: absolute; left: 0; top: 4px; width: 10px; height: 10px; border-radius: 50%; box-sizing: border-box; border: 2px solid var(--c); background: var(--c); }
+.tl li.tl-quiet::before { background: var(--surface); }
+.tl li::after { content: ''; position: absolute; left: 4px; top: 16px; bottom: 0; width: 2px; border-radius: 2px; background: var(--c); opacity: .55; }
+.tl li:last-child { padding-bottom: 0; } .tl li:last-child::after { display: none; }
+.tl .tl-claimed { --c: var(--blue); } .tl .tl-submitted { --c: var(--warn); } .tl .tl-verified { --c: var(--accent); } .tl .tl-withdrawn { --c: var(--ink-faint); } .tl .tl-back { --c: var(--reject); }
+.tl b { font-weight: 600; }
+.tl small { grid-column: 2; color: var(--ink-faint); font-size: 12px; }
+.tl time, .feed time { color: var(--ink-faint); font: 12px var(--mono); }
+.rowref { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; font-size: 13px; padding: 3px 0; }
+.rowref code { font-weight: 600; }
+.links { display: flex; flex-wrap: wrap; gap: 6px; }
+.links button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 6px; padding: 3px 9px; cursor: pointer; font-size: 12.5px; }
+
+.panel-form { display: grid; gap: 10px; }
+.panel-form label, .inline label { display: grid; gap: 4px; font-size: 12px; color: var(--ink-muted); }
+.panel-form input, .panel-form select, .panel-form textarea, .inline input, .inline select { width: 100%; }
+.panel-form textarea { resize: vertical; }
+.actions { display: flex; gap: 8px; } .actions .go { flex: 1; }
+.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; padding: 10px; }
+.inline label { flex: 1 1 150px; min-width: 0; }
+.inline label.wide { flex: 4 1 260px; }
+.feed { padding: 6px 10px 10px; display: grid; }
+.feed > div { display: grid; grid-template-columns: 4.6em minmax(0, 1fr); gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); overflow-wrap: break-word; }
+.feed > .empty { display: block; }
+.feed > div:first-child, .feed > .day + div { border-top: 0; }
+.feed .day { margin: 0; padding: 12px 0 4px; font: 600 11px/1 var(--mono); letter-spacing: .07em; text-transform: uppercase; color: var(--ink-faint); }
+.feed .day:first-child { padding-top: 6px; }
+.feed button.ref, .ask button.ref, .detail button.ref { border: 0; background: none; padding: 0; color: var(--accent-strong); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; display: inline; min-height: 0; vertical-align: baseline; line-height: inherit; font: inherit; }
+code.inline { padding: 0 3px; border-radius: 3px; background: color-mix(in srgb, var(--ink) 8%, var(--surface)); font: .92em var(--mono); white-space: break-spaces; }
+.code { display: block; margin: 6px 0 2px; padding: 6px 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); font: 12px/1.55 var(--mono); white-space: pre; overflow-x: auto; overflow-wrap: normal; }
+.code > span { display: block; padding-right: 12px; }
+.code i { display: inline-block; min-width: 3.2em; padding: 0 10px 0 6px; text-align: right; font-style: normal; color: var(--ink-faint); user-select: none; }
+.code .more, .code.no { padding: 2px 10px; white-space: normal; color: var(--ink-muted); }
+.code.no { color: var(--reject); }
+.feed .act { display: flex; gap: 0 5px; align-items: baseline; min-width: 0; }
+.feed .act .what { flex: 1 1 auto; min-width: 0; overflow-wrap: break-word; color: var(--ink-muted); }
+.agent { display: grid; gap: 2px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; }
+.agent:first-child { border-top: 0; }
+.agent small { color: var(--ink-faint); font: 11.5px var(--mono); overflow-wrap: anywhere; }
+.agent > div { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
+.agent > div > .muted { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.agent time { margin-left: auto; color: var(--ink-faint); font: 12px var(--mono); }
+.agent button { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; width: 100%; border: 0; background: none; padding: 2px 0; text-align: left; cursor: pointer; }
+.agent button > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.agent button:hover > span:first-child { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px; }
+.lane { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); font-size: 13px; }
+.lane:first-child { border-top: 0; }
+.rows { padding: 4px 10px 10px; }
+.rows h4 { margin: 12px 0 4px; font-size: 12.5px; color: var(--ink-muted); }
+.srow { display: grid; grid-template-columns: 4.4em 6.2em minmax(0, 1fr); gap: 8px; padding: 6px 4px; border-top: 1px solid var(--line); align-items: baseline; cursor: pointer; border-radius: 6px; }
+.srow:hover { background: var(--surface-2); }
+.srow.on { background: var(--accent-soft); }
+.srow code { font: 600 12px var(--mono); }
+.rule-source, .rule-reason { display: block; color: var(--ink-muted); font-size: 11.5px; line-height: 1.5; }
+.rule-reason { margin-top: 3px; }
+@media (width < 480px) { .srow { grid-template-columns: auto minmax(0, 1fr); } .srow > span:last-child { grid-column: 1 / -1; } }
+.flow { position: relative; margin: 0 0 12px; padding: 10px 12px 8px; overflow-x: auto; }
+.flow svg { display: block; width: 100%; min-width: 680px; max-width: 920px; height: auto; margin: 0 auto; }
+.flow figcaption { color: var(--ink-faint); font-size: 12px; padding: 2px 34px 0 2px; }
+.flow-hide { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border: 0; border-radius: 8px; background: none; color: var(--ink-faint); font: 18px/1 var(--sans); cursor: pointer; }
+.flow-hide:hover { background: var(--surface-2); color: var(--ink); }
+.flow-show { margin: 0 0 12px; }
+.flow .box { fill: var(--surface-2); stroke: var(--line-strong); stroke-width: 1.2; }
+.flow .box.inner { fill: none; }
+.flow .s-verified .box { fill: var(--accent-soft); stroke: var(--accent); } .flow .s-verified .box.inner { fill: none; }
+.flow .name { font: 600 11px var(--mono); letter-spacing: .06em; fill: var(--ink-faint); }
+.flow .n { font: 800 22px var(--sans); fill: var(--ink); }
+.flow .keep { font: 11px var(--sans); fill: var(--ink-muted); } .flow .keep.idle { fill: var(--ink-faint); }
+.flow .sub { font: 11px var(--sans); fill: var(--reject); }
+.flow .edge { fill: none; stroke: var(--line-strong); stroke-width: 1.4; }
+.flow .edge.back { stroke: var(--reject); stroke-dasharray: 5 4; }
+.flow marker path { fill: var(--line-strong); } .flow marker.back path { fill: var(--reject); }
+.flow .tag { font: 12px var(--sans); fill: var(--ink-muted); }
+.flow .tag.idle { fill: var(--ink-faint); } .flow .tag.back { fill: var(--reject); }
+.flow g:hover > .box, .flow g:hover > .edge { stroke-width: 2.2; }
+.console { position: static; width: min(560px, calc(100% - 32px)); margin: 8px auto; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow); padding: 10px 12px; font: 12px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 38vh; overflow: auto; cursor: pointer; }
+.console.ok { border-color: var(--accent); } .console.no { border-color: var(--reject); }
+.snapshot-controls:not([hidden]) { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; padding: 12px 16px; }
+.snapshot-controls > span { font-weight: 600; }
+.snapshot-controls label { display: flex; align-items: center; gap: 6px; }
+.snapshot-controls output { color: var(--ink-muted); font: 12px/1.5 var(--mono); }
+.snapshot #new-item, .snapshot form, .snapshot [data-new], .snapshot [data-release], .snapshot [data-shout], .snapshot [data-go^="decide:"] { display: none !important; }
+.read-only #new-item, .read-only form, .read-only [data-new], .read-only [data-release], .read-only [data-shout], .read-only [data-go^="decide:"] { display: none !important; }
+
+/* Every action keeps a usable touch target at either viewport, including inline controls. */
+button, input, select, textarea, [data-item], [data-row] { min-height: 44px; }
+.theme-btn, .flow-hide { width: 44px; height: 44px; }
+.seg { flex-wrap: wrap; max-width: 100%; }
+.inline > label { min-width: 0; }
+@media (width < 480px) {
+ .toolbar .seg { flex: 1 1 100%; }
+}
diff --git a/docs/shots/capture-browser.mjs b/docs/shots/capture-browser.mjs
new file mode 100644
index 00000000..15b35ab7
--- /dev/null
+++ b/docs/shots/capture-browser.mjs
@@ -0,0 +1,75 @@
+/** Real Chrome capture with explicit document and data readiness (I13,A10). */
+import { spawn } from 'node:child_process';
+import { readFile, writeFile } from 'node:fs/promises';
+import { join } from 'node:path';
+import { evaluationValue } from './devtools-evaluation.mjs';
+
+/** Allow Chrome or the page's next response to advance before another read-only observation. */
+const pause = (ms) => new Promise((resolvePause) => setTimeout(resolvePause, ms));
+
+/** Stop this owned Chrome process and await its sockets and profile release. */
+async function stop(child) {
+ if (child.exitCode !== null || child.signalCode !== null) return;
+ child.kill();
+ await new Promise((resolveStop) => child.once('close', resolveStop));
+}
+
+/** Start Chrome with a disposable profile and return the DevTools connection for its page. */
+export async function browser(chrome, profile, url) {
+ const child = spawn(chrome, ['--headless=new', '--disable-gpu', '--no-proxy-server', '--use-mock-keychain', '--password-store=basic', '--no-first-run', '--no-default-browser-check', '--disable-background-networking', '--disable-sync', '--disable-extensions', '--remote-debugging-port=0', `--user-data-dir=${profile}`, '--window-size=1440,1100', 'about:blank'], { stdio: 'ignore' });
+ let socket;
+ let port;
+ try {
+ for (let n = 0; n < 100 && !port; n++) {
+ try { port = (await readFile(join(profile, 'DevToolsActivePort'), 'utf8')).split('\n')[0]; } catch {}
+ if (!port) await pause(100);
+ }
+ if (!port) throw new Error('Chrome did not start');
+ const response = await fetch(`http://127.0.0.1:${port}/json/new?${encodeURIComponent('about:blank')}`, { method: 'PUT' });
+ if (!response.ok) throw new Error('Chrome could not open the demo view');
+ const target = await response.json();
+ socket = new WebSocket(target.webSocketDebuggerUrl);
+ await new Promise((ok, fail) => { socket.addEventListener('open', ok, { once: true }); socket.addEventListener('error', fail, { once: true }); });
+ let id = 0;
+ const pending = new Map();
+ socket.addEventListener('message', ({ data }) => { const m = JSON.parse(String(data)); const waiter = pending.get(m.id); if (waiter) { pending.delete(m.id); m.error ? waiter.reject(new Error('Chrome operation failed: ' + m.error.message)) : waiter.resolve(m.result); } });
+ /** Bound a protocol operation so a stalled renderer cannot strand Chrome or a capture. */
+ const send = (method, params = {}) => new Promise((ok, fail) => {
+ const key = ++id;
+ const timer = setTimeout(() => { pending.delete(key); fail(new Error(`Chrome operation timed out: ${method}`)); }, 30_000);
+ pending.set(key, { resolve: (value) => { clearTimeout(timer); ok(value); }, reject: (error) => { clearTimeout(timer); fail(error); } });
+ socket.send(JSON.stringify({ id: key, method, params }));
+ });
+ await send('Page.enable');
+ await send('Runtime.enable');
+ const evaluate = async (expression) => evaluationValue(await send('Runtime.evaluate', { expression, awaitPromise: true, returnByValue: true }));
+ /** Wait for a read-only page condition; a timeout is a failed capture, never a silent success. */
+ async function waitFor(expression, label, timeoutMs = 30_000) {
+ const deadline = Date.now() + timeoutMs;
+ while (Date.now() < deadline) {
+ if (await evaluate(expression)) return;
+ await pause(100);
+ }
+ throw new Error(`The demo page did not become ready: ${label}`);
+ }
+ await send('Page.navigate', { url });
+ await waitFor(`location.href === ${JSON.stringify(url)} && document.readyState === 'complete'`, 'intended HTTP document');
+ return {
+ evaluate,
+ waitFor,
+ viewport: (width, height) => send('Emulation.setDeviceMetricsOverride', { width, height, deviceScaleFactor: 1, mobile: false }),
+ screenshot: async (path) => { const result = await send('Page.captureScreenshot', { format: 'png', captureBeyondViewport: false }); await writeFile(path, Buffer.from(result.data, 'base64')); },
+ close: async () => { socket.close(); await stop(child); },
+ };
+ } catch (error) {
+ socket?.close();
+ await stop(child);
+ throw error;
+ }
+}
+
+/** Wait for this demo's API data and rendered controls before storage writes or selection. */
+export async function waitForDemoBoard(view, repo) {
+ const ready = `typeof data !== 'undefined' && data?.project?.root === ${JSON.stringify(repo)} && data.root === view.root && data.projects.some(project => project.root === ${JSON.stringify(repo)} && project.ok && project.name === 'Demo board') && data.project.items.some(item => item.id === 1 && item.title === 'Reviewed and accepted' && item.verdicts.some(verdict => verdict.decision === 'REJECT') && item.verdicts.at(-1)?.decision === 'ACCEPT') && !!document.querySelector('#state-chips [data-state=all]')`;
+ await view.waitFor(ready, 'populated demo board and complete review history');
+}
diff --git a/docs/shots/capture-browser.test.js b/docs/shots/capture-browser.test.js
new file mode 100644
index 00000000..d14ecb04
--- /dev/null
+++ b/docs/shots/capture-browser.test.js
@@ -0,0 +1,76 @@
+/** Real Chrome readiness over the disposable demo's exported API (I13,A10). */
+import assert from 'node:assert/strict';
+import { spawnSync } from 'node:child_process';
+import { mkdtemp, readFile, rm } from 'node:fs/promises';
+import { createServer } from 'node:http';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { test } from 'node:test';
+import { browser, waitForDemoBoard } from './capture-browser.mjs';
+
+/** Let the browser process a pending protocol reply without releasing either server barrier. */
+const pause = (ms) => new Promise((resolvePause) => setTimeout(resolvePause, ms));
+
+/** Make a server barrier and a signal for the first request waiting behind it. */
+function barrier() {
+ let release;
+ let observed;
+ return { pending: new Promise((resolve) => { release = resolve; }), received: new Promise((resolve) => { observed = resolve; }), release: () => release(), observed: () => observed() };
+}
+
+test('demo capture waits for the intended HTTP document and populated board in Chrome [I13,A10]', { timeout: 90_000 }, async (t) => {
+ const chrome = [process.env.PULLBOARD_CHROME, '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser'].filter(Boolean).find((file) => spawnSync(file, ['--version'], { stdio: 'ignore' }).status === 0);
+ if (!chrome) return t.skip('Install Chrome to prove demo capture readiness.');
+ const base = await mkdtemp(join(tmpdir(), 'pullboard-demo-capture-'));
+ const document = barrier();
+ const state = barrier();
+ const stylesheet = barrier();
+ const server = createServer(async (request, response) => {
+ const path = new URL(request.url, 'http://localhost').pathname;
+ if (path === '/') { document.observed(); await document.pending; }
+ if (path.endsWith('/view.css')) { stylesheet.observed(); await stylesheet.pending; }
+ if (path.endsWith('/state.json')) { state.observed(); await state.pending; }
+ try {
+ const body = await readFile(new URL('../demo/' + (path === '/' ? 'index.html' : path.slice(1)), import.meta.url));
+ response.setHeader('Content-Type', path.endsWith('.json') ? 'application/json' : path.endsWith('.css') ? 'text/css' : 'text/html');
+ response.end(body);
+ } catch { response.writeHead(404).end(); }
+ });
+ await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
+ const url = `http://127.0.0.1:${server.address().port}/`;
+ let opened = false;
+ const opening = browser(chrome, join(base, 'profile'), url).then((view) => { opened = true; return view; });
+ // Attach immediately so a genuine bootstrap failure cannot become an unhandled rejection.
+ opening.catch(() => {});
+ let view;
+ try {
+ await Promise.race([document.received, opening.then(() => document.received)]);
+ await pause(150);
+ assert.equal(opened, false, 'about:blank complete must not count as the intended HTTP document');
+ document.release();
+ await Promise.race([stylesheet.received, opening.then(() => stylesheet.received)]);
+ await pause(150);
+ assert.equal(opened, false, 'a committed HTTP document with a pending stylesheet must not count as complete');
+ stylesheet.release();
+ view = await opening;
+ assert.equal(await view.evaluate('location.href'), url);
+ let ready = false;
+ const populated = waitForDemoBoard(view, 'demo-board').then(() => { ready = true; });
+ populated.catch(() => {});
+ await state.received;
+ await pause(150);
+ assert.equal(ready, false, 'complete HTML must not count as populated board data');
+ state.release();
+ await populated;
+ assert.equal(await view.evaluate("data.project.root === 'demo-board' && !!document.querySelector('#chain .row[data-item=\"1\"]')"), true);
+ assert.equal(await view.evaluate("localStorage.setItem('capture-proof', 'ready'); localStorage.getItem('capture-proof')"), 'ready');
+ await assert.rejects(view.waitFor('false', 'impossible capture state', 150), /did not become ready: impossible capture state/);
+ } finally {
+ document.release(); state.release(); stylesheet.release();
+ if (!view) view = await opening.catch(() => null);
+ if (view) await view.close();
+ server.closeAllConnections();
+ await new Promise((resolve) => server.close(resolve));
+ await rm(base, { recursive: true, force: true });
+ }
+});
diff --git a/docs/shots/demo.mjs b/docs/shots/demo.mjs
index 7a864d6b..d5e162ba 100644
--- a/docs/shots/demo.mjs
+++ b/docs/shots/demo.mjs
@@ -4,18 +4,21 @@
* The disposable repo and private PULLBOARD_HOME keep personal projects and shouts out of the art.
*/
import { spawn, spawnSync } from 'node:child_process';
-import { mkdtemp, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
+import { mkdtemp, mkdir, readFile, realpath, rename, rm, writeFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
-import { evaluationValue } from './devtools-evaluation.mjs';
+import { browser, waitForDemoBoard } from './capture-browser.mjs';
+import { AGENT_SHELL_MARKERS } from '../../src/person.js';
import { renderTour } from './tour-renderer.mjs';
const ROOT = resolve(fileURLToPath(new URL('../..', import.meta.url)));
const BIN = join(ROOT, 'bin', 'pullboard.js');
const OUTPUT = fileURLToPath(new URL('./', import.meta.url));
+const DEMO_OUTPUT = join(ROOT, 'docs', 'demo');
+const DEMO_BOARD_ID = 'demo-board';
+const FIXED_TIME = '2026-10-06T12:00:00.000Z';
const CHROME = ['/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser'];
-const pause = (ms) => new Promise((resolvePause) => setTimeout(resolvePause, ms));
/** Run a pullboard or git command in the disposable demo environment. */
function command(file, args, cwd, env) {
@@ -31,47 +34,28 @@ async function stop(child) {
await new Promise((resolveStop) => child.once('close', resolveStop));
}
-/** Make a child environment with a private home and no inherited git overrides. */
-function isolatedEnv(home) {
- const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => !key.startsWith('GIT_')));
- return { ...env, HOME: home, PULLBOARD_HOME: home, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1', GIT_AUTHOR_NAME: 'Pullboard demo', GIT_AUTHOR_EMAIL: '[email protected]', GIT_COMMITTER_NAME: 'Pullboard demo', GIT_COMMITTER_EMAIL: '[email protected]' };
+/** Model a person terminal only inside the disposable demo, with a private home and no Git overrides. */
+function isolatedEnv(home, clockShim) {
+ const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => !key.startsWith('GIT_') && key !== 'NODE_OPTIONS' && !AGENT_SHELL_MARKERS.includes(key)));
+ return { ...env, HOME: home, PULLBOARD_HOME: home, PULLBOARD_MACHINE_HOME: home, NODE_OPTIONS: `--import ${JSON.stringify(clockShim)}`, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1', GIT_AUTHOR_NAME: 'Pullboard demo', GIT_AUTHOR_EMAIL: '[email protected]', GIT_COMMITTER_NAME: 'Pullboard demo', GIT_AUTHOR_DATE: FIXED_TIME, GIT_COMMITTER_DATE: FIXED_TIME };
}
-/** Start Chrome with a disposable profile and return the DevTools connection for its page. */
-async function browser(chrome, profile, url) {
- const child = spawn(chrome, ['--headless=new', '--no-first-run', '--no-default-browser-check', '--disable-background-networking', '--disable-sync', '--disable-extensions', '--remote-debugging-port=0', `--user-data-dir=${profile}`, '--window-size=1440,1100', 'about:blank'], { stdio: 'ignore' });
- let socket;
- let port;
- try {
- for (let n = 0; n < 100 && !port; n++) {
- try { port = (await readFile(join(profile, 'DevToolsActivePort'), 'utf8')).split('\n')[0]; } catch {}
- if (!port) await pause(100);
- }
- if (!port) throw new Error('Chrome did not start');
- const response = await fetch(`http://127.0.0.1:${port}/json/new?${encodeURIComponent(url)}`, { method: 'PUT' });
- if (!response.ok) throw new Error('Chrome could not open the demo view');
- const target = await response.json();
- socket = new WebSocket(target.webSocketDebuggerUrl);
- await new Promise((ok, fail) => { socket.addEventListener('open', ok, { once: true }); socket.addEventListener('error', fail, { once: true }); });
- let id = 0;
- const pending = new Map();
- socket.addEventListener('message', ({ data }) => { const m = JSON.parse(String(data)); const waiter = pending.get(m.id); if (waiter) { pending.delete(m.id); m.error ? waiter.reject(new Error('Chrome operation failed')) : waiter.resolve(m.result); } });
- const send = (method, params = {}) => new Promise((ok, fail) => { const key = ++id; pending.set(key, { resolve: ok, reject: fail }); socket.send(JSON.stringify({ id: key, method, params })); });
- await send('Page.enable');
- await send('Runtime.enable');
- const evaluate = async (expression) => evaluationValue(await send('Runtime.evaluate', { expression, awaitPromise: true, returnByValue: true }));
- for (let n = 0; n < 100 && await evaluate('document.readyState') !== 'complete'; n++) await pause(100);
- return {
- evaluate,
- viewport: (width, height) => send('Emulation.setDeviceMetricsOverride', { width, height, deviceScaleFactor: 1, mobile: false }),
- screenshot: async (path) => { const result = await send('Page.captureScreenshot', { format: 'png', captureBeyondViewport: false }); await writeFile(path, Buffer.from(result.data, 'base64')); },
- close: async () => { socket.close(); await stop(child); },
- };
- } catch (error) {
- socket?.close();
- await stop(child);
- throw error;
- }
+/** Export the board, then replace its random storage id with a stable public snapshot id. */
+async function exportBoard(repo, env) {
+ await rm(DEMO_OUTPUT, { recursive: true, force: true });
+ command(process.execPath, [BIN, 'view', '--export', DEMO_OUTPUT], repo, env);
+ const listingPath = join(DEMO_OUTPUT, 'api', 'v1', 'boards.json');
+ const listing = JSON.parse(await readFile(listingPath, 'utf8'));
+ if (listing.boards.length !== 1) throw new Error('The demo export must contain exactly one board.');
+ const source = join(DEMO_OUTPUT, 'api', 'v1', 'boards', listing.boards[0].id);
+ const target = join(DEMO_OUTPUT, 'api', 'v1', 'boards', DEMO_BOARD_ID);
+ await rename(source, target);
+ listing.boards[0].id = DEMO_BOARD_ID;
+ await writeFile(listingPath, JSON.stringify(listing) + '\n');
+ const statePath = join(target, 'state.json');
+ const state = JSON.parse(await readFile(statePath, 'utf8'));
+ state.state.board = DEMO_BOARD_ID;
+ await writeFile(statePath, JSON.stringify(state) + '\n');
}
/** Build the demo board by issuing real commands in a temporary git repo. */
@@ -80,23 +64,25 @@ async function buildBoard(base, env) {
await mkdir(repo, { recursive: true });
command('git', ['init', '-q', '-b', 'main'], repo, env);
command(process.execPath, [BIN, 'init'], repo, env);
- await writeFile(join(repo, 'pullboard.json'), JSON.stringify({ gate: 'node --check src/demo.js', spec: 'SPEC.md', verify: 'any', lease: '2h', lanes: { app: { owns: ['src/'], specs: ['G'] }, review: { owns: [], specs: [] } }, shared: [] }, null, 2) + '\n');
- await writeFile(join(repo, 'SPEC.md'), '# Demo\n\n## G · Goals\n- G1 [approved, must] A demo item exists to show the board. | gate: none\n');
+ await writeFile(join(repo, 'pullboard.json'), JSON.stringify({ name: 'Demo board', project: 'Pullboard demo', gate: 'node --check src/demo.js', spec: 'SPEC.md', verify: { policy: 'any', family: 'require' }, lease: '2h', lanes: { app: { owns: ['src/'], specs: ['G'] }, review: { owns: [], specs: [] } }, shared: [] }, null, 2) + '\n');
+ await writeFile(join(repo, 'SPEC.md'), '# Demo\n\n## G · Goals\n- G1 [approved, must] A demo item exists to show the board. | gate: none\n- G2 [approved, must] The verified item shows its review history. | gate: none\n');
command('git', ['add', '-A'], repo, env);
command('git', ['commit', '-q', '-m', 'chore: initialize demo board'], repo, env);
const pb = (cwd, ...args) => command(process.execPath, [BIN, ...args], cwd, env);
pb(repo, 'add', 'app', 'Reviewed and accepted', '--specs', 'G1', '--criterion', 'The demo item is accepted after review.');
- pb(repo, 'add', 'app', 'Open for rework', '--specs', 'G1', '--criterion', 'The demo item remains open after rejection.');
+ pb(repo, 'add', 'app', 'Future work', '--specs', 'G1', '--criterion', 'The board keeps another item open for later work.');
pb(repo, 'add', 'app', 'Ready for review', '--specs', 'G1', '--criterion', 'The demo item is submitted for review.');
pb(repo, 'add', 'app', 'Claimed for work', '--specs', 'G1', '--criterion', 'The demo item is being worked on.');
- pb(repo, 'add', 'app', 'Open decision', '--specs', 'G1', '--criterion', 'The demo has a pending decision.');
+ pb(repo, 'add', 'app', 'Decision follow-up', '--specs', 'G1', '--criterion', 'The board keeps a follow-up visible after the person answers.');
pb(repo, 'add', 'app', 'Withdrawn example', '--specs', 'G1', '--criterion', 'The demo includes withdrawn work.');
pb(repo, 'withdraw', '6', 'this example was dropped');
const app = pb(repo, 'worktree', 'app').match(/made (.+) on branch app\/1/)?.[1];
if (!app) throw new Error('Could not create the demo builder worktree');
+ pb(app, 'join', 'app', '--family', 'codex');
const review = pb(repo, 'worktree', 'review').match(/made (.+) on branch review\/1/)?.[1];
if (!review) throw new Error('Could not create the demo reviewer worktree');
+ pb(review, 'join', 'review', '--family', 'claude');
pb(app, 'next');
await mkdir(join(app, 'src'), { recursive: true });
await writeFile(join(app, 'src', 'demo.js'), 'export const reviewed = false;\n');
@@ -118,6 +104,7 @@ async function buildBoard(base, env) {
pb(repo, 'merged', '1', second);
const app2 = pb(repo, 'worktree', 'app').match(/made (.+) on branch app\/2/)?.[1];
if (!app2) throw new Error('Could not create the second demo builder worktree');
+ pb(app2, 'join', 'app', '--family', 'codex');
pb(app2, 'claim', '3');
await mkdir(join(app2, 'src'), { recursive: true });
await writeFile(join(app2, 'src', 'review.js'), 'export const ready = true;\n');
@@ -126,10 +113,21 @@ async function buildBoard(base, env) {
pb(app2, 'submit', '3');
const app3 = pb(repo, 'worktree', 'app').match(/made (.+) on branch app\/3/)?.[1];
if (!app3) throw new Error('Could not create the third demo builder worktree');
+ pb(app3, 'join', 'app', '--family', 'codex');
pb(app3, 'claim', '4');
- pb(repo, 'shout', 'app', 'Decision needed: should this change wait for another reviewer?', '--decision');
- pb(repo, 'shout', 'all', 'Demo receipt: the fixture is isolated and the accepted revision was checked.', '--evidence', 'receipt', '--outcome', 'accepted', '--item', '1', '--commit', second);
+ const decision = pb(app3, 'shout', 'coordinator', 'The review is complete. May the verified change proceed?', '--decision').match(/as #(\d+)/)?.[1];
+ if (!decision) throw new Error('The demo decision request was not recorded.');
+ const passed = pb(repo, 'pass', decision, 'The review passed; ask the person before proceeding.').match(/as #(\d+)/)?.[1];
+ if (!passed) throw new Error('The coordinator did not pass the demo decision to the person.');
+ pb(repo, 'answer', passed, 'Proceed with the verified change.', '--as', 'person');
+ pb(repo, 'hold', 'review', '--reason', 'Waiting for the next demo item.');
if (!/1 withdrawn/.test(pb(repo, 'status'))) throw new Error('The demo board must include a withdrawn item.');
+ const item = JSON.parse(pb(repo, 'show', '1', '--json'));
+ if (item.item_builder_family !== 'codex' || item.verdicts.at(-1)?.verdict_verifier_family !== 'claude') {
+ throw new Error('The accepted demo item must be verified by another declared model family.');
+ }
+ const doctrine = JSON.parse(pb(repo, 'spec', '--json'));
+ if (!doctrine.rows.some((row) => row.origin === 'standard')) throw new Error('The demo board must include standard doctrine.');
return repo;
}
@@ -158,15 +156,18 @@ const tourOnly = process.argv.includes('--tour-only');
const chrome = !tourOnly && CHROME.find((path) => { try { return spawnSync(path, ['--version'], { stdio: 'ignore' }).status === 0; } catch { return false; } });
if (!chrome && !tourOnly) { process.stderr.write('pullboard demo: install Google Chrome to capture the board screenshots.\n'); process.exitCode = 1; }
else {
- const base = await mkdtemp(join(tmpdir(), 'pullboard-readme-demo-'));
+ const base = await realpath(await mkdtemp(join(tmpdir(), 'pullboard-readme-demo-')));
let view;
let server;
try {
- const env = { ...isolatedEnv(join(base, '.pullboard-home')), TMPDIR: base, TMP: base, TEMP: base };
+ const clockShim = join(base, 'fixed-clock.mjs');
+ await writeFile(clockShim, `const NativeDate = Date;\nconst fixed = NativeDate.parse(${JSON.stringify(FIXED_TIME)});\nclass FixedDate extends NativeDate { constructor(...args) { super(...(args.length ? args : [fixed])); } static now() { return fixed; } }\nglobalThis.Date = FixedDate;\n`);
+ const env = { ...isolatedEnv(join(base, '.pullboard-home'), clockShim), TMPDIR: base, TMP: base, TEMP: base };
if (tourOnly) {
await recordTour(env);
} else {
const repo = await buildBoard(base, env);
+ await exportBoard(repo, env);
server = spawn(process.execPath, [BIN, 'view', '--no-open'], { cwd: repo, env, stdio: ['ignore', 'pipe', 'ignore'] });
const url = await new Promise((resolveUrl, reject) => {
let output = '';
@@ -176,11 +177,13 @@ else {
server.once('close', () => { clearTimeout(timer); reject(new Error('The demo view stopped before it opened')); });
});
view = await browser(chrome, join(base, 'chrome-profile'), url);
- await pause(700);
+ await waitForDemoBoard(view, repo);
await view.viewport(1440, 700);
- const detail = await view.evaluate("(()=>{document.documentElement.dataset.theme='light'; localStorage.setItem('pb.theme','light'); document.querySelector('[data-state=all]')?.click(); const item=document.querySelector('[data-item=\"1\"]'); if(!item) throw new Error('accepted item #1 is missing'); item.click(); return document.querySelector('#detail').textContent})()");
- if (!detail.includes('REJECT') || !detail.includes('ACCEPT')) throw new Error('The desktop screenshot must show item #1 rejected and accepted.');
- await pause(350);
+ await view.evaluate("document.querySelector('[data-state=all]').click()");
+ await view.waitFor("!!document.querySelector('#chain .row[data-item=\"1\"]')", 'accepted item in All');
+ await view.evaluate("(()=>{document.documentElement.dataset.theme='light'; localStorage.setItem('pb.theme','light'); document.querySelector('#chain .row[data-item=\"1\"]').click()})()");
+ await view.waitFor("view.item === 1 && !!document.querySelector('#chain .row.on[data-item=\"1\"]') && document.querySelector('#detail').textContent.includes('Reviewed and accepted') && document.querySelector('#detail').textContent.includes('REJECT') && document.querySelector('#detail').textContent.includes('ACCEPT')", 'selected accepted item and both verdicts');
+ await view.evaluate('document.fonts.ready.then(() => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve))))');
await view.screenshot(join(OUTPUT, 'desktop.png'));
await view.viewport(390, 900);
await view.evaluate("(()=>{document.documentElement.dataset.theme='dark'; localStorage.setItem('pb.theme','dark'); const item=document.querySelector('[data-item=\"1\"]'); const detail=document.querySelector('#detail')?.textContent??''; if(document.documentElement.dataset.theme!=='dark'||!item||!detail.includes('ACCEPT')) throw new Error('The phone screenshot must show the selected accepted item in dark mode'); return true})()");
diff --git a/docs/shots/desktop.png b/docs/shots/desktop.png
index 6a544ceb..fd0c2471 100644
Binary files a/docs/shots/desktop.png and b/docs/shots/desktop.png differ
diff --git a/docs/shots/phone.png b/docs/shots/phone.png
index 62b1e8fb..ddb7b2eb 100644
Binary files a/docs/shots/phone.png and b/docs/shots/phone.png differ
diff --git a/docs/shots/shots.test.js b/docs/shots/shots.test.js
index ad52f72d..9761b2c5 100644
--- a/docs/shots/shots.test.js
+++ b/docs/shots/shots.test.js
@@ -6,6 +6,7 @@ import assert from 'node:assert/strict';
import { readFileSync, statSync } from 'node:fs';
import { join } from 'node:path';
import { test } from 'node:test';
+import { fileURLToPath } from 'node:url';
import { evaluationValue } from './devtools-evaluation.mjs';
import { renderTour } from './tour-renderer.mjs';
@@ -40,6 +41,55 @@ test('the demo assets exist and stay within their size budgets [I11,I13]', () =>
assert.doesNotMatch(tour, /[\x00-\x08\x0b-\x1f]/, 'tour SVG contains no XML-invalid control characters');
});
+test('the exported demo records cross-family review, a passed and answered decision, and standard doctrine [I13,A10]', () => {
+ const listing = JSON.parse(readFileSync(new URL('docs/demo/api/v1/boards.json', ROOT), 'utf8'));
+ assert.equal(listing.boards.length, 1);
+ assert.deepEqual({ id: listing.boards[0].id, root: listing.boards[0].root, name: listing.boards[0].name },
+ { id: 'demo-board', root: 'demo-board', name: 'Demo board' });
+ const base = 'docs/demo/api/v1/boards/demo-board/';
+ const state = JSON.parse(readFileSync(new URL(base + 'state.json', ROOT), 'utf8')).state;
+ assert.equal(state.board, 'demo-board', 'the snapshot refers to its stable public board id');
+ const events = JSON.parse(readFileSync(new URL(base + 'events.json', ROOT), 'utf8')).events;
+ const reviewed = state.items.find((item) => item.id === 1);
+ assert.equal(reviewed.status, 'verified');
+ assert.deepEqual(reviewed.verdicts.map((verdict) => verdict.decision), ['REJECT', 'ACCEPT']);
+ const familyOf = (id) => state.agents.find((agent) => agent.agent_id === id)?.agent_family;
+ assert.equal(familyOf(reviewed.builtBy), 'codex');
+ assert.equal(familyOf(reviewed.verdicts.at(-1).by), 'claude');
+ assert.notEqual(familyOf(reviewed.builtBy), familyOf(reviewed.verdicts.at(-1).by));
+ assert.ok(events.some((event) => event.event_kind === 'family' && JSON.parse(event.event_detail).family === 'codex'));
+ assert.ok(events.some((event) => event.event_kind === 'family' && JSON.parse(event.event_detail).family === 'claude'));
+ assert.ok(events.some((event) => event.event_kind === 'reject' && event.item_id === 1));
+ assert.ok(events.some((event) => event.event_kind === 'accept' && event.item_id === 1));
+ const joinedLanes = new Set(events.filter((event) => event.event_kind === 'join').map((event) => JSON.parse(event.event_detail).lane));
+ assert.deepEqual([...joinedLanes].sort(), ['app', 'coordinator', 'review']);
+ assert.ok(state.items.some((item) => item.status === 'claimed'));
+ assert.ok(state.items.some((item) => item.status === 'submitted'));
+ assert.deepEqual(state.spec.filter((row) => row.status === 'approved').map((row) => row.id), ['G1', 'G2']);
+ assert.ok(state.practice.some((row) => row.origin === 'standard'), 'the snapshot contains the shipped standard doctrine');
+ assert.ok(state.holds.some((hold) => hold.hold_lane === 'review'));
+ const ask = events.findIndex((event) => event.event_kind === 'shout' && JSON.parse(event.event_detail).decision === true);
+ const pass = events.findIndex((event, index) => index > ask && event.event_kind === 'pass' && event.event_by === 'coordinator');
+ const answer = events.findIndex((event, index) => index > pass && event.event_kind === 'answer' && event.event_by === 'person');
+ assert.ok(ask >= 0 && pass > ask && answer > pass, 'the coordinator passes the decision up and the person answers afterward');
+});
+
+test('the exported demo is synthetic and contains no machine paths or unrelated shouts [I13,A10]', () => {
+ const files = ['index.html', 'view.css', 'api/v1/boards.json', 'api/v1/boards/demo-board/state.json', 'api/v1/boards/demo-board/events.json'];
+ const text = files.map((file) => readFileSync(new URL('docs/demo/' + file, ROOT), 'utf8')).join('\n');
+ assert.equal(text.includes(fileURLToPath(ROOT)), false, 'the export does not name this checkout');
+ if (process.env.HOME) assert.equal(text.includes(process.env.HOME), false, 'the export does not name the person home');
+ assert.doesNotMatch(text, /file:\/\/|\/(?:Users|private)\/|\/tmp\/pullboard-/);
+ const state = JSON.parse(readFileSync(new URL('docs/demo/api/v1/boards/demo-board/state.json', ROOT), 'utf8')).state;
+ assert.ok(state.agents.every((agent) => /^(coordinator|person|app-\d+|review-\d+)$/.test(agent.agent_id)), 'only generic demo roles appear as agents');
+ assert.ok(state.shouts.every((shout) => [
+ 'The review is complete. May the verified change proceed?',
+ 'Passed up from app-3: The review is complete. May the verified change proceed?\nCoordinator note: The review passed; ask the person before proceeding.',
+ 'Proceed with the verified change.',
+ 'Person answered #2: Proceed with the verified change.',
+ ].includes(shout.shout_text)), 'the board contains only the synthetic decision exchange');
+});
+
test('the demo rebuild script uses a temporary repo and isolated home [I11,I13]', () => {
const script = readFileSync(shots('demo.mjs'), 'utf8');
assert.match(script, /mkdtemp\(join\(tmpdir\(\)/);
diff --git a/docs/shots/tour.svg b/docs/shots/tour.svg
index feac3132..b6186efc 100644
--- a/docs/shots/tour.svg
+++ b/docs/shots/tour.svg
@@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" class="tour-card" viewBox="0 0 640 420" width="640" height="420" role="img" aria-labelledby="tour-title tour-description">
<title id="tour-title">The tour, in thirty seconds</title><desc id="tour-description">Eight steps: a real change is submitted, rejected, fixed, tested and accepted before it merges.</desc>
-<metadata id="tour-transcript">[{&quot;text&quot;:&quot;pullboard tour: a coordinator and two scripted agents run real commands on a throwaway repo. No model runs.&quot;,&quot;at&quot;:83},{&quot;text&quot;:&quot;1 The person approved one spec row. The coordinator files it as work.&quot;,&quot;at&quot;:4013},{&quot;text&quot;:&quot; G1: greet(name) returns \&quot;Hello, &lt;name&gt;!\&quot;; a blank name greets the world: \&quot;Hello, world!\&quot;&quot;,&quot;at&quot;:4013},{&quot;text&quot;:&quot; coordinator $ pullboard add app Greeting --specs G1 --criterion \&quot;greet() meets G1\&quot;&quot;,&quot;at&quot;:4419},{&quot;text&quot;:&quot; #1&quot;,&quot;at&quot;:4531},{&quot;text&quot;:&quot;2 A builder agent gets its own worktree in the app lane and claims the next item. Its criterion freezes.&quot;,&quot;at&quot;:5733},{&quot;text&quot;:&quot; coordinator $ pullboard worktree app&quot;,&quot;at&quot;:6135},{&quot;text&quot;:&quot; made greeter-app-1 on branch app/1, joined as app-1 in the app lane&quot;,&quot;at&quot;:6423},{&quot;text&quot;:&quot; app-1 $ pullboard next&quot;,&quot;at&quot;:6827},{&quot;text&quot;:&quot; claimed #1: Greeting&quot;,&quot;at&quot;:6963},{&quot;text&quot;:&quot; criterion: greet() meets G1&quot;,&quot;at&quot;:6963},{&quot;text&quot;:&quot;3 It writes greet(), tests the happy path and submits. Its own gate is green.&quot;,&quot;at&quot;:8165},{&quot;text&quot;:&quot; app-1 $ git commit -q -m \&quot;feat(app): greet by name [G1]\&quot;&quot;,&quot;at&quot;:8997},{&quot;text&quot;:&quot; app-1 $ pullboard submit 1&quot;,&quot;at&quot;:10051},{&quot;text&quot;:&quot; submitted #1 at 39784bfbd0df; gate green in 0s&quot;,&quot;at&quot;:10445},{&quot;text&quot;:&quot;4 A second agent checks out exactly that commit and tries the edge the builder skipped.&quot;,&quot;at&quot;:11650},{&quot;text&quot;:&quot; coordinator $ pullboard worktree review&quot;,&quot;at&quot;:12055},{&quot;text&quot;:&quot; made greeter-review-1 on branch review/1, joined as review-1 in the review lane&quot;,&quot;at&quot;:12189},{&quot;text&quot;:&quot; review-1 $ git switch -q --detach 39784bfbd0df&quot;,&quot;at&quot;:12593},{&quot;text&quot;:&quot; review-1 $ node -e \&quot;greet(&apos;&apos;)\&quot;&quot;,&quot;at&quot;:13005},{&quot;text&quot;:&quot; Hello, !&quot;,&quot;at&quot;:13036},{&quot;text&quot;:&quot; review-1 $ pullboard verify 1 reject --reason BEHAVIOR_MISMATCH --note \&quot;greet(&apos;&apos;) returns \\\&quot;Hello, !\\\&quot;; G1 says a blank name greets the world\&quot;&quot;,&quot;at&quot;:13438},{&quot;text&quot;:&quot; rejected #1: BEHAVIOR_MISMATCH; it is open again for rework&quot;,&quot;at&quot;:13524},{&quot;text&quot;:&quot;5 The builder&apos;s next session starts from the board, not from memory.&quot;,&quot;at&quot;:14725},{&quot;text&quot;:&quot; app-1 $ pullboard resume&quot;,&quot;at&quot;:15131},{&quot;text&quot;:&quot; sent back: #1 BEHAVIOR_MISMATCH by review-1: greet(&apos;&apos;) returns \&quot;Hello, !\&quot;; G1 says a blank name greets the world&quot;,&quot;at&quot;:15225},{&quot;text&quot;:&quot; next: pullboard claim 1, fix what the verifier found, and submit again&quot;,&quot;at&quot;:15225},{&quot;text&quot;:&quot;6 It fixes the edge, adds a test that pins it, and submits a new commit.&quot;,&quot;at&quot;:16430},{&quot;text&quot;:&quot; app-1 $ pullboard claim 1&quot;,&quot;at&quot;:16834},{&quot;text&quot;:&quot; claimed #1 until 2026-10-07T20:37:32.544Z; criterion frozen as e2a1226a8e16&quot;,&quot;at&quot;:16927},{&quot;text&quot;:&quot; app-1 $ git commit -q -am \&quot;fix(app): a blank name greets the world [G1]\&quot;&quot;,&quot;at&quot;:17329},{&quot;text&quot;:&quot; app-1 $ pullboard submit 1&quot;,&quot;at&quot;:17997},{&quot;text&quot;:&quot; submitted #1 at 2900e83fe968; gate green in 0s&quot;,&quot;at&quot;:18235},{&quot;text&quot;:&quot;7 The verifier breaks the fix on purpose, to prove the new test can fail, then restores it and accepts.&quot;,&quot;at&quot;:19441},{&quot;text&quot;:&quot; review-1 $ git switch -q --detach 2900e83fe968&quot;,&quot;at&quot;:19846},{&quot;text&quot;:&quot; review-1 $ node --test # with the fix removed&quot;,&quot;at&quot;:20264},{&quot;text&quot;:&quot; # pass 1&quot;,&quot;at&quot;:20345},{&quot;text&quot;:&quot; # fail 1&quot;,&quot;at&quot;:20345},{&quot;text&quot;:&quot; review-1 $ git checkout -- src/greet.mjs&quot;,&quot;at&quot;:20750},{&quot;text&quot;:&quot; review-1 $ pullboard verify 1 accept --note \&quot;removed the blank-name fix: its new test failed; restored, both pass\&quot;&quot;,&quot;at&quot;:21167},{&quot;text&quot;:&quot; verified #1: CRITERION_MET&quot;,&quot;at&quot;:21258},{&quot;text&quot;:&quot;8 The coordinator merges it. The ledger is the receipt.&quot;,&quot;at&quot;:22462},{&quot;text&quot;:&quot; coordinator $ git merge -q --ff-only app/1&quot;,&quot;at&quot;:22867},{&quot;text&quot;:&quot; coordinator $ pullboard merged 1 2900e83fe968&quot;,&quot;at&quot;:23297},{&quot;text&quot;:&quot; #1 merged as 2900e83fe968&quot;,&quot;at&quot;:23380},{&quot;text&quot;:&quot; coordinator $ pullboard ledger&quot;,&quot;at&quot;:23782},{&quot;text&quot;:&quot; 1 verified by a second agent · 0 awaiting verification · 1 rejection along the way&quot;,&quot;at&quot;:23858},{&quot;text&quot;:&quot; | # | Lane | Item | Spec | Built by | Verified by | Commit | Merged |&quot;,&quot;at&quot;:23858},{&quot;text&quot;:&quot; | 1 | app | Greeting | G1 | app-1 | review-1 | 2900e83fe968 | 2900e83fe968 |&quot;,&quot;at&quot;:23858},{&quot;text&quot;:&quot;Nothing shipped until a second agent verified it.&quot;,&quot;at&quot;:23858},{&quot;text&quot;:&quot; Look around: cd greeter &amp;&amp; pullboard log&quot;,&quot;at&quot;:23858}]</metadata>
+<metadata id="tour-transcript">[{&quot;text&quot;:&quot;pullboard tour: a coordinator and two scripted agents run real commands on a throwaway repo. No model runs.&quot;,&quot;at&quot;:126},{&quot;text&quot;:&quot;1 The person approved one spec row. The coordinator files it as work.&quot;,&quot;at&quot;:5488},{&quot;text&quot;:&quot; G1: greet(name) returns \&quot;Hello, &lt;name&gt;!\&quot;; a blank name greets the world: \&quot;Hello, world!\&quot;&quot;,&quot;at&quot;:5488},{&quot;text&quot;:&quot; coordinator $ pullboard add app Greeting --specs G1 --criterion \&quot;greet() meets G1\&quot;&quot;,&quot;at&quot;:5893},{&quot;text&quot;:&quot; #1&quot;,&quot;at&quot;:6067},{&quot;text&quot;:&quot;2 A builder agent gets its own worktree in the app lane and claims the next item. Its criterion freezes.&quot;,&quot;at&quot;:7269},{&quot;text&quot;:&quot; coordinator $ pullboard worktree app&quot;,&quot;at&quot;:7676},{&quot;text&quot;:&quot; made greeter-app-1 on branch app/1, joined as app-1 in the app lane&quot;,&quot;at&quot;:7956},{&quot;text&quot;:&quot; app-1 $ pullboard next&quot;,&quot;at&quot;:8359},{&quot;text&quot;:&quot; claimed #1: Greeting&quot;,&quot;at&quot;:8549},{&quot;text&quot;:&quot; criterion: greet() meets G1&quot;,&quot;at&quot;:8549},{&quot;text&quot;:&quot;3 It writes greet(), tests the happy path and submits. Its own gate is green.&quot;,&quot;at&quot;:9751},{&quot;text&quot;:&quot; app-1 $ git commit -q -m \&quot;feat(app): greet by name [G1]\&quot;&quot;,&quot;at&quot;:10564},{&quot;text&quot;:&quot; app-1 $ pullboard submit 1&quot;,&quot;at&quot;:11992},{&quot;text&quot;:&quot; submitted #1 at 2fc236927c49; gate green in 0s&quot;,&quot;at&quot;:12467},{&quot;text&quot;:&quot;4 A second agent checks out exactly that commit and tries the edge the builder skipped.&quot;,&quot;at&quot;:13668},{&quot;text&quot;:&quot; coordinator $ pullboard worktree review&quot;,&quot;at&quot;:14073},{&quot;text&quot;:&quot; made greeter-review-1 on branch review/1, joined as review-1 in the review lane&quot;,&quot;at&quot;:14243},{&quot;text&quot;:&quot; review-1 $ git switch -q --detach 2fc236927c49&quot;,&quot;at&quot;:14653},{&quot;text&quot;:&quot; review-1 $ node -e \&quot;greet(&apos;&apos;)\&quot;&quot;,&quot;at&quot;:15060},{&quot;text&quot;:&quot; Hello, !&quot;,&quot;at&quot;:15089},{&quot;text&quot;:&quot; review-1 $ pullboard verify 1 reject --reason BEHAVIOR_MISMATCH --note \&quot;greet(&apos;&apos;) returns \\\&quot;Hello, !\\\&quot;; G1 says a blank name greets the world\&quot;&quot;,&quot;at&quot;:15492},{&quot;text&quot;:&quot; rejected #1: BEHAVIOR_MISMATCH; it is open again for rework&quot;,&quot;at&quot;:15629},{&quot;text&quot;:&quot;5 The builder&apos;s next session starts from the board, not from memory.&quot;,&quot;at&quot;:16830},{&quot;text&quot;:&quot; app-1 $ pullboard resume&quot;,&quot;at&quot;:17238},{&quot;text&quot;:&quot; sent back: #1 BEHAVIOR_MISMATCH by review-1: greet(&apos;&apos;) returns \&quot;Hello, !\&quot;; G1 says a blank name greets the world&quot;,&quot;at&quot;:17361},{&quot;text&quot;:&quot; next: pullboard claim 1, fix what the verifier found, and submit again&quot;,&quot;at&quot;:17361},{&quot;text&quot;:&quot;6 It fixes the edge, adds a test that pins it, and submits a new commit.&quot;,&quot;at&quot;:18569},{&quot;text&quot;:&quot; app-1 $ pullboard claim 1&quot;,&quot;at&quot;:18973},{&quot;text&quot;:&quot; claimed #1 until 2026-10-06T14:00:00.000Z; criterion frozen as b3c2476468c4&quot;,&quot;at&quot;:19080},{&quot;text&quot;:&quot; app-1 $ git commit -q -am \&quot;fix(app): a blank name greets the world [G1]\&quot;&quot;,&quot;at&quot;:19482},{&quot;text&quot;:&quot; app-1 $ pullboard submit 1&quot;,&quot;at&quot;:20189},{&quot;text&quot;:&quot; submitted #1 at 9946029102f9; gate green in 0s&quot;,&quot;at&quot;:20523},{&quot;text&quot;:&quot;7 The verifier breaks the fix on purpose, to prove the new test can fail, then restores it and accepts.&quot;,&quot;at&quot;:21733},{&quot;text&quot;:&quot; review-1 $ git switch -q --detach 9946029102f9&quot;,&quot;at&quot;:22142},{&quot;text&quot;:&quot; review-1 $ node --test # with the fix removed&quot;,&quot;at&quot;:22559},{&quot;text&quot;:&quot; # pass 1&quot;,&quot;at&quot;:22624},{&quot;text&quot;:&quot; # fail 1&quot;,&quot;at&quot;:22624},{&quot;text&quot;:&quot; review-1 $ git checkout -- src/greet.mjs&quot;,&quot;at&quot;:23035},{&quot;text&quot;:&quot; review-1 $ pullboard verify 1 accept --note \&quot;removed the blank-name fix: its new test failed; restored, both pass\&quot;&quot;,&quot;at&quot;:23447},{&quot;text&quot;:&quot; verified #1: CRITERION_MET&quot;,&quot;at&quot;:23595},{&quot;text&quot;:&quot;8 The coordinator merges it. The ledger is the receipt.&quot;,&quot;at&quot;:24801},{&quot;text&quot;:&quot; coordinator $ git merge -q --ff-only app/1&quot;,&quot;at&quot;:25209},{&quot;text&quot;:&quot; coordinator $ pullboard merged 1 9946029102f9&quot;,&quot;at&quot;:25628},{&quot;text&quot;:&quot; #1 merged as 9946029102f9&quot;,&quot;at&quot;:25754},{&quot;text&quot;:&quot; coordinator $ pullboard ledger&quot;,&quot;at&quot;:26156},{&quot;text&quot;:&quot; 1 verified by a second agent · 0 awaiting verification · 1 rejection along the way&quot;,&quot;at&quot;:26249},{&quot;text&quot;:&quot; | # | Lane | Item | Spec | Built by | Verified by | Commit | Merged |&quot;,&quot;at&quot;:26249},{&quot;text&quot;:&quot; | 1 | app | Greeting | G1 | app-1 | review-1 | 9946029102f9 | 9946029102f9 |&quot;,&quot;at&quot;:26249},{&quot;text&quot;:&quot;Nothing shipped until a second agent verified it.&quot;,&quot;at&quot;:26249},{&quot;text&quot;:&quot; Look around: cd greeter &amp;&amp; pullboard log&quot;,&quot;at&quot;:26249}]</metadata>
<style>
.tour-card{--surface:#ffffff;--line:#dce5df;--ink:#101714;--muted:#4f5b55;--faint:#65746b;--blue:#315f8f;--violet:#6547bc;--green:#087546;--green-soft:#dff4e8;--red:#b33026;--red-soft:#fce8e5;--highlight:#edf7f1;font-family:system-ui,-apple-system,"Segoe UI",sans-serif}
@media(prefers-color-scheme:dark){.tour-card{--surface:#111714;--line:#34443a;--ink:#e9eeeb;--muted:#b6c3bc;--faint:#9cafa3;--blue:#80bfff;--violet:#c1aeff;--green:#61e6b1;--green-soft:#163829;--red:#ff8a80;--red-soft:#321917;--highlight:#193426}}