feat(orchestrator): draw agents and chairs as a matrix organigram

The agents hierarchy gains a matrix org chart: agents as columns, chairs as rows, so one agent with several chairs shows every one of them; a Home tile can pin it. Tests run once on unify/skills-20261114 after the merge (operator order 2026-11-14).

🎯 Fix: 82 %
💥 Break: 8 %
💸 Tokens: 90 %
⏱️ Velocity: 90 %
🛡️ Security: 100 %
🏆 Score: 93
🚦 Gate: ⛔ fix 82 % < 90, break 8 % > 5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-14 21:31:47 +00:00
1 parent 48f26b678a
commit 2b4c3baaa0
8 files changed
+641 -68

No files matched your search

+1 -1
View File
@@ -470,7 +470,7 @@ Stream → Radio (`#stream/radio`) is the hub's radio interface. Its station lis
The hub page loads nothing from the network: its icons come from Bootstrap Icons 1.13.1 (`orchestrator/vendor/bootstrap-icons`, MIT), inlined per page as the symbols it uses, and its 3D views from `3d-force-graph` 1.80.1 and `three` 0.186.1 (`orchestrator/vendor`, MIT, served by the hub under `/vendor/`); the speech bubbles use Comic Neue 400 latin from `@fontsource/comic-neue` 5.3.0 (`orchestrator/vendor/comic-neue`, SIL OFL 1.1), which the page fetches and adds through the FontFace API, so the CSP needs no `font-src`. In the Artifacts Tree, "Delete" on a `merged-clean` branch without skip reason, or "Delete all merged", shows the dry-run lines and asks for the passkey signature; the hub then writes a job (repository, branch, worktree and tip per item, no command) into `~/.local/state/kvb-orchestrator/cleanup/jobs`. The `kvb-orchestrator-cleanup.path` user unit runs `client/cleanup.py` on the host, which verifies the signature against the pinned keys, runs `pkgmgr branch cleanup --json --local --branch <name>` as a dry run in the repository, then `--apply` only when that plan names exactly the signed branch as `merged-clean` at the signed tip and worktree, refuses everything else unchanged, writes each result to `cleanup/results` and rewrites the tree file. The buttons stay disabled while the tree file says `delete_ready: false`.
The Agents view "Hierarchy" draws the council's formal offices as a collapsible org chart: Operator, chair, dimensions with their line representatives, organisers (`cluster/<slug>`) and presidents (`work/<slug>`); the chair in every graph is the holder of the `chair` office, not a fixed name. Appointing, handing over or recalling an office there asks for the passkey signature; the hub writes a job (office, signed holder, successor session, work; no command) into `~/.local/state/kvb-orchestrator/offices/jobs`, and the `kvb-orchestrator-offices.path` user unit runs `client/offices.py` on the host, which verifies the signature, refuses a council directory others can write, a link on the path or a holder that changed since the signature. For a takeover or recall it moves the office aside and removes it only while the claim there still names the signed holder; an appoint or takeover then runs a plain `council.py claim <office>` for the successor by argv. council.py itself has no flag that overrides a live holder. The same view holds the operator's agent order as a drag list with up and down buttons: `rasci.py agents order` stores it in `agent-order.json` beside the register, where it breaks ties of equal task priority and orders the chair's grants without touching any task's `--prio` pin.
The Agents view "Hierarchy" draws the council's formal offices as a collapsible organigram: the Operator above the chair; in line under the chair one unit per dimension with its domain chairs (`<dimension>/<line>`) and one for the presidents (`work/<slug>`); beside the chair, on a side branch, the staff positions: organisers (`cluster/<slug>`) and single-segment offices such as `stack-architecture`. Each box shows the office and its holder, so an agent with several offices appears in each of them. A dashed line marks an additional superior, read live from the `kvb-org-rasci` register: an open task whose R (or worker) holds an office and that names another office holder A or C links that holder's first office to the agent's office for the task (the office or claimed work named like the task, else the agent's first office); the chair adds none, its solid line already runs there. On a narrow screen the chart scrolls inside its own frame, never the page. The chair in every graph is the holder of the `chair` office, not a fixed name. Appointing, handing over or recalling an office there asks for the passkey signature; the hub writes a job (office, signed holder, successor session, work; no command) into `~/.local/state/kvb-orchestrator/offices/jobs`, and the `kvb-orchestrator-offices.path` user unit runs `client/offices.py` on the host, which verifies the signature, refuses a council directory others can write, a link on the path or a holder that changed since the signature. For a takeover or recall it moves the office aside and removes it only while the claim there still names the signed holder; an appoint or takeover then runs a plain `council.py claim <office>` for the successor by argv. council.py itself has no flag that overrides a live holder. The same view holds the operator's agent order as a drag list with up and down buttons: `rasci.py agents order` stores it in `agent-order.json` beside the register, where it breaks ties of equal task priority and orders the chair's grants without touching any task's `--prio` pin.
The Tasks tab (key 4, `#tasks/list`, `#tasks/board`, `#tasks/rasci`) shows the `kvb-org-rasci` register as a list, a board by status and a RASCI matrix; queue jobs from `council/queue.json` appear as "waiting for a grant", and the filter "Waits on Operator" is the inbox, which the Inbox entry under Stream opens: every pending review, ask, rule request, operator row and choice card, with no Choices column of its own. The Tasks toolbar is one row that wraps on narrow screens (views, filter, estimation, sort and business value, trend on the burn view), the status chips the second; every list row shows its ETA, and `#tasks/3d` draws the tasks and their dependencies on the 3D engine. Its "Request choices" dropdown has one button per channel, post and call to the agents ticked in it, newsletter, broadcast, pan-pan, Sécurité and mayday to all, that sends the fixed request "send me your open decisions as choices" without a text field, one passkey assertion over every recipient (`/api/choices/sign`, then `/api/choices`). Agents answer with `decision_request`, shown as choice cards, and a click on an option is the passkey-signed answer: after the 3 s undo the hub verifies the signature and posts the answer to the asking agent, whose `decision_wait` returns it as `message` and `answer` for `operator_message`. A task's sheet pins its priority (`rasci.py set <task> --prio <n>`) or sets and drops the operator's WSJF estimate (`rasci.py estimate <task> Operator --value <fib> --complexity <fib>` or `--drop`) after a passkey signature; the hub writes an argv-only job, and the runner, started with `--rasci <rasci.py> --council <council root>`, verifies it like an operator command and runs `rasci.py` from `/` without a shell, killing it after 30 s. Agent order stays untouched. The install copies the fresh runner unit and restarts the runner when it is enabled, and only while the installed `council.py`, `nofollow.py` and `rasci.py` match this tree: otherwise it disables the runner and asks for `make install`. The runner unit pins `PATH` to `/usr/bin:/bin`, so a signed command names any other program by its full path; a runner started without `--rasci` and `--council` keeps running signed commands and refuses task changes, and so does one whose council is a symlink or another uid's. Each worktree in the tree file may carry `"flow": {"pull": [...], "push": [...], "source": "file"}` or `null`, which the Tree, the Chord edges, the detail panel and the matching task show; a malformed flow shows as `invalid`. Worktrees and tasks with open work (uncommitted, unpushed, unmerged, task not done) carry a warning bar.
+2
View File
@@ -503,6 +503,8 @@ pre.notes { margin: 0; padding: 8px 10px; background: var(--sunken); border-radi
{% include "plan.js" %}
{% include "kanban.js" %}
{% include "organigram.js" %}
</script>
<script nonce="{{ nonce }}">
{# Jinja drops each file's last newline and trim_blocks the one after the tag: the blank lines keep consecutive modules on separate lines #}
+173
View File
@@ -0,0 +1,173 @@
const Organigram = (() => {
"use strict";
const LINE_KINDS = ["line", "work"];
const RANK = ["chair", "line", "work", "cluster", "other"];
const SUPERIOR = ["A", "C"];
const PRESIDENTS = {id: "group:work", kind: "work", label: "Presidents"};
const BEND = 36;
const byName = (a, b) => a.localeCompare(b, "en");
const byOffice = (a, b) => byName(a.office, b.office);
const rankOf = (claim) => (RANK.includes(claim.kind) ? RANK.indexOf(claim.kind) : RANK.length);
const ranked = (a, b) => rankOf(a) - rankOf(b) || byOffice(a, b);
/**
* @param claim - a council claim with its kind: chair, line, work, cluster or other.
* @returns "chair" for the chair; "line" for a domain chair (<dimension>/<line>) and a work/* president, both in line
* under the chair; "staff" for a cluster/* organizer and every single-segment office, drawn beside the chair.
*/
function position(claim) {
if (claim.kind === "chair") {
return "chair";
}
return LINE_KINDS.includes(claim.kind) ? "line" : "staff";
}
/**
* @param claims - the council claims.
* @returns {chair, staff, units}: chair the chair's claim or null; staff the staff positions, organizers before the
* other offices, each by office; units the line units, one per dimension by name and then the presidents, each
* {id, kind, label, positions} with its positions by office.
*/
function chart(claims) {
const lines = claims.filter((claim) => position(claim) === "line").sort(byOffice);
const dimensions = [...new Set(lines.filter((claim) => claim.kind === "line").map((claim) => claim.dimension))].sort(byName);
const units = dimensions.map((dimension) => ({id: `dimension:${dimension}`, kind: "dimension", label: dimension, positions: lines.filter((claim) => claim.kind === "line" && claim.dimension === dimension)}));
const presidents = lines.filter((claim) => claim.kind === "work");
return {
chair: claims.find((claim) => claim.kind === "chair") || null,
staff: claims.filter((claim) => position(claim) === "staff").sort(ranked),
units: presidents.length ? [...units, {...PRESIDENTS, positions: presidents}] : units,
};
}
function officesOf(claims) {
const offices = new Map();
for (const claim of claims.filter((entry) => entry.agent).sort(ranked)) {
offices.set(claim.agent, [...(offices.get(claim.agent) || []), claim]);
}
return offices;
}
function doers(row, offices) {
const responsible = Object.entries(row.roles).filter(([, letters]) => letters.includes("R")).map(([party]) => party);
return [...new Set([...responsible, row.worker])].filter((name) => offices.has(name));
}
function superiors(row, agent, offices) {
return Object.entries(row.roles)
.map(([party, letters]) => ({party, letters: SUPERIOR.filter((letter) => letters.includes(letter)).join("")}))
.filter(({party, letters}) => party !== agent && letters && offices.has(party))
.map(({party, letters}) => ({office: offices.get(party)[0], letters}))
.filter(({office}) => office.kind !== "chair");
}
function targets(row, own) {
const named = own.filter((claim) => claim.office === row.task || claim.work === row.task);
return named.length ? named : [own[0]];
}
function join(edges, from, to, letters, task) {
const key = `${from.office}\n${to.office}`;
const edge = edges.get(key) || {from: from.office, to: to.office, letters: "", tasks: []};
edges.set(key, {...edge, letters: SUPERIOR.filter((letter) => edge.letters.includes(letter) || letters.includes(letter)).join(""), tasks: [...new Set([...edge.tasks, task])].sort(byName)});
}
/**
* @param claims - the council claims, each with its holder as agent.
* @param tasks - the register's task rows, each {task, ended, worker, roles: {party: letters}}.
* @returns the dashed edges, one {from, to, letters, tasks} per pair of offices, by from then to: an open task whose R
* (or worker) holds an office and that names another office holder A or C makes that holder's first office (chair,
* domain chair, president, organizer, other office; then by name) an additional superior of the agent's office for
* the task (the office or the claimed work named like the task, else the agent's first office). letters holds the A
* and C of the pair, tasks its tasks by name. A superior holding the chair adds no edge: the solid line runs there.
*/
function dotted(claims, tasks) {
const offices = officesOf(claims);
const edges = new Map();
for (const row of tasks.filter((entry) => !entry.ended && entry.roles)) {
for (const agent of doers(row, offices)) {
for (const {office, letters} of superiors(row, agent, offices)) {
targets(row, offices.get(agent)).forEach((to) => join(edges, office, to, letters, row.task));
}
}
}
return [...edges.values()].sort((a, b) => byName(a.from, b.from) || byName(a.to, b.to));
}
const round = (value) => Math.round(value * 10) / 10;
const centerX = (box) => (box.left + box.right) / 2;
const centerY = (box) => (box.top + box.bottom) / 2;
const segment = (x1, y1, x2, y2) => `M ${round(x1)} ${round(y1)} L ${round(x2)} ${round(y2)}`;
function elbow(from, to) {
const middle = round((from.bottom + to.top) / 2);
return `M ${round(centerX(from))} ${round(from.bottom)} V ${middle} H ${round(centerX(to))} V ${round(to.top)}`;
}
function stem(chair, staff, units) {
if (!staff.length && !units.length) {
return [];
}
const x = centerX(chair);
const tops = units.map((unit) => unit.box.top);
const bus = tops.length ? Math.min(...tops) - BEND / 2 : null;
const lowest = Math.max(chair.bottom, ...staff.map(centerY), ...(bus === null ? [] : [bus]));
const branches = staff.map((box) => segment(x, centerY(box), centerX(box) < x ? box.right : box.left, centerY(box)));
const drops = units.map((unit) => segment(centerX(unit.box), bus, centerX(unit.box), unit.box.top));
const rail = units.length ? [segment(Math.min(...units.map((unit) => centerX(unit.box)), x), bus, Math.max(...units.map((unit) => centerX(unit.box)), x), bus)] : [];
return [segment(x, chair.bottom, x, lowest), ...branches, ...rail, ...drops];
}
function comb(unit) {
if (!unit.positions.length) {
return [];
}
const x = unit.box.left + BEND / 2;
const last = centerY(unit.positions[unit.positions.length - 1]);
return [segment(x, unit.box.bottom, x, last), ...unit.positions.map((box) => segment(x, centerY(box), box.left, centerY(box)))];
}
/**
* @param boxes - the drawn boxes as {left, top, right, bottom} in chart coordinates, folded ones left out:
* {root, chair, staff: [box], units: [{box, positions: [box]}]}; root and chair may be null.
* @returns the path data of the solid lines: root to chair, the chair's stem with its staff branches, the rail and
* drops to the units, and each unit's comb to its positions.
*/
function solid(boxes) {
const top = boxes.root && boxes.chair ? [elbow(boxes.root, boxes.chair)] : [];
const below = boxes.chair ? stem(boxes.chair, boxes.staff, boxes.units) : [];
return [...top, ...below, ...boxes.units.flatMap(comb)];
}
function anchors(from, to) {
if (from.left < to.right && to.left < from.right) {
const side = Math.max(from.right, to.right) + BEND;
return [[from.right, centerY(from)], [side, centerY(from)], [side, centerY(to)], [to.right, centerY(to)]];
}
if (to.top >= from.bottom || to.bottom <= from.top) {
const [a, b] = to.top >= from.bottom ? [from.bottom, to.top] : [from.top, to.bottom];
const middle = (a + b) / 2;
return [[centerX(from), a], [centerX(from), middle], [centerX(to), middle], [centerX(to), b]];
}
const [a, b] = centerX(to) > centerX(from) ? [from.right, to.left] : [from.left, to.right];
const middle = (a + b) / 2;
return [[a, centerY(from)], [middle, centerY(from)], [middle, centerY(to)], [b, centerY(to)]];
}
/**
* @param from - the superior's box as {left, top, right, bottom}.
* @param to - the subordinate's box.
* @returns the path data of a curve from the superior's box to the subordinate's: around the right side when the two
* share a column, else from the facing edges.
*/
function dashed(from, to) {
const [start, one, two, end] = anchors(from, to).map((point) => point.map(round).join(" "));
return `M ${start} C ${one} ${two} ${end}`;
}
return {position, chart, dotted, solid, dashed};
})();
if (typeof module === "object" && module.exports) {
module.exports = Organigram;
}
+137 -53
View File
@@ -1,6 +1,7 @@
const hier = {chart: null, sig: "", closed: new Set(), ids: 0};
const OFFICE_ICONS = {chair: "bi-award", line: "bi-person-badge", cluster: "bi-collection", work: "bi-briefcase", other: "bi-signpost-split"};
const OFFICE_GROUPS = [["cluster", "Organizers", "Organizer"], ["work", "Presidents", "President"], ["other", "Other offices", "Office"]];
const OFFICE_TITLES = {chair: "Chair", line: "Domain chair", work: "President", cluster: "Organizer", other: "Office"};
const UNIT_ICONS = {dimension: "bi-diagram-2", work: "bi-briefcase"};
function hierarchyScreen() {
hier.chart = h("section", {class: "card org-chart", "data-panel": "agents/hierarchy", "aria-labelledby": "org-title"});
@@ -12,7 +13,7 @@
function hierarchySig() {
const held = state.claims.map((claim) => [claim.office, claim.session, claim.agent, claim.work, claim.beat !== null && claim.beat >= state.now - ACTIVE_BEAT]);
return JSON.stringify([held, state.agent_order, state.people, state.presence, [...look.hidden]]);
return JSON.stringify([held, Organigram.dotted(state.claims, state.tasks), state.agent_order, state.people, state.presence, [...look.hidden]]);
}
function drawHierarchy(force) {
@@ -51,38 +52,14 @@
return claim.agent || (claim.session === "-" ? "" : claim.session);
}
function officeRow(claim, label, title) {
const who = holderOf(claim);
const active = claim.beat !== null && claim.beat >= state.now - ACTIVE_BEAT;
return h("div", {class: "org-row", "data-office": claim.office},
h("span", {class: "org-office", title: `${title} ${claim.office}`}, icon(OFFICE_ICONS[claim.kind]), h("strong", {}, label)),
who ? h("button", {type: "button", class: "linkish org-holder", "data-focus": `agent:${claim.office}`, title: `Open ${who}`, on: {click: () => openAgent(who, near(`#main [data-focus="agent:${CSS.escape(claim.office)}"]`))}}, face(who, false), who) : h("span", {class: "muted"}, "–"),
claim.session === "-" ? null : presenceMark(claim.session, false),
active ? chip("bi-play-circle", "active", "ok") : chip("bi-pause-circle", "no heartbeat", "neutral"),
claim.work && claim.work !== "-" ? h("span", {class: "muted org-work", title: claim.work}, short(claim.work)) : null,
h("span", {class: "org-actions"},
officeBtn("bi-arrow-left-right", "Hand over", `Hand over: ${claim.office} to another session, with a passkey signature`, () => officeSheet("takeover", claim), `takeover:${claim.office}`),
officeBtn("bi-person-x", "Recall", `Recall: free ${claim.office}, with a passkey signature`, () => officeSheet("recall", claim), `recall:${claim.office}`)));
}
function vacantRow(office, label) {
return h("div", {class: "org-row vacant", "data-office": office},
h("span", {class: "org-office"}, icon(OFFICE_ICONS.chair), h("strong", {}, label)),
pill("vacant", "warn"),
h("span", {class: "org-actions"}, officeBtn("bi-person-plus", "Appoint", `Appoint: give ${office} to a session, with a passkey signature`, () => officeSheet("appoint", {office, session: "", work: ""}), `appoint:${office}`)));
}
function groupRow(glyph, label, count, note) {
return h("div", {class: "org-row group"}, h("span", {class: "org-office"}, icon(glyph), h("strong", {}, label)), counter(count), h("span", {class: "muted"}, note));
}
function orgNode(id, label, row, children) {
if (!children.length) {
return h("li", {}, h("div", {class: "org-line"}, h("span", {class: "org-gap", "aria-hidden": "true"}), row));
}
const open = !hier.closed.has(id);
function nextOrgId() {
hier.ids += 1;
const list = h("ul", {class: "org-tree", id: `org-${hier.ids}`, hidden: !open}, children);
return `org-${hier.ids}`;
}
function folder(id, label, list) {
const open = !hier.closed.has(id);
list.hidden = !open;
const toggle = h("button", {type: "button", class: "btn small ghost icon-only org-toggle", "aria-expanded": String(open), "aria-controls": list.id, "data-focus": `toggle:${id}`, ...named(`${open ? "Collapse" : "Expand"}: ${label}`)}, icon(open ? "bi-chevron-down" : "bi-chevron-right"));
toggle.addEventListener("click", () => {
const now = list.hidden;
@@ -94,37 +71,144 @@
} else {
hier.closed.add(id);
}
drawLinks(list.closest(".organigram"));
});
return h("li", {"data-node": id}, h("div", {class: "org-line"}, toggle, row), list);
return toggle;
}
function chartTree() {
const claims = state.claims;
const dimensions = new Map();
for (const claim of claims.filter((entry) => entry.kind === "line")) {
dimensions.set(claim.dimension, [...(dimensions.get(claim.dimension) || []), claim]);
function officeHead(claim, toggle) {
const title = OFFICE_TITLES[claim.kind] || OFFICE_TITLES.other;
return h("div", {class: "org-head"}, toggle,
h("span", {class: "org-office", title: `${title} ${claim.office}`}, icon(OFFICE_ICONS[claim.kind] || OFFICE_ICONS.other),
h("span", {class: "org-name"}, claim.kind === "chair" ? h("strong", {}, title) : [h("span", {class: "org-title"}, title), h("strong", {}, claim.office)])));
}
function holderLine(claim) {
const who = holderOf(claim);
const active = claim.beat !== null && claim.beat >= state.now - ACTIVE_BEAT;
return h("div", {class: "org-who"},
who ? h("button", {type: "button", class: "linkish org-holder", "data-focus": `agent:${claim.office}`, title: `Open ${who}`, on: {click: () => openAgent(who, near(`#main [data-focus="agent:${CSS.escape(claim.office)}"]`))}}, face(who, false), who) : h("span", {class: "muted"}, "–"),
claim.session === "-" ? null : presenceMark(claim.session, false),
active ? chip("bi-play-circle", "active", "ok") : chip("bi-pause-circle", "no heartbeat", "neutral"));
}
function dottedLines(claim, edges) {
return edges.filter((edge) => edge.to === claim.office).map((edge) => h("div", {class: "org-dotted", "data-from": edge.from, title: `Additional superior from the register: ${edge.letters} on ${edge.tasks.join(", ")}`},
icon("bi-bezier2"), `Also under ${edge.from} (${edge.letters})`));
}
function officeBox(claim, edges, toggle) {
return h("div", {class: `org-row org-box${claim.kind === "chair" ? " org-chair" : ""}`, "data-office": claim.office, "data-kind": claim.kind, "data-position": Organigram.position(claim)},
officeHead(claim, toggle),
holderLine(claim),
claim.work && claim.work !== "-" ? h("span", {class: "muted org-work", title: claim.work}, short(claim.work)) : null,
dottedLines(claim, edges),
h("span", {class: "org-actions"},
officeBtn("bi-arrow-left-right", "Hand over", `Hand over: ${claim.office} to another session, with a passkey signature`, () => officeSheet("takeover", claim), `takeover:${claim.office}`),
officeBtn("bi-person-x", "Recall", `Recall: free ${claim.office}, with a passkey signature`, () => officeSheet("recall", claim), `recall:${claim.office}`)));
}
function vacantBox(toggle) {
return h("div", {class: "org-row org-box org-chair vacant", "data-office": "chair", "data-kind": "chair", "data-position": "chair"},
h("div", {class: "org-head"}, toggle, h("span", {class: "org-office"}, icon(OFFICE_ICONS.chair), h("strong", {}, "Chair"))),
pill("vacant", "warn"),
h("span", {class: "org-actions"}, officeBtn("bi-person-plus", "Appoint", "Appoint: give chair to a session, with a passkey signature", () => officeSheet("appoint", {office: "chair", session: "", work: ""}), "appoint:chair")));
}
function unitNode(unit, edges) {
const list = h("ul", {class: "org-positions", id: nextOrgId()}, unit.positions.map((claim) => h("li", {}, officeBox(claim, edges, null))));
const note = unit.kind === "work" ? "work/…" : unit.positions.length === 1 ? "line" : "lines";
return h("li", {class: "org-unit", "data-node": unit.id},
h("div", {class: "org-row group org-box org-unit-box", "data-unit": unit.id},
h("div", {class: "org-head"}, folder(unit.id, unit.label, list), h("span", {class: "org-office"}, icon(UNIT_ICONS[unit.kind]), h("strong", {}, unit.label)), counter(unit.positions.length), h("span", {class: "muted"}, note))),
list);
}
function chairPart(chair, staff, units, edges) {
const below = h("div", {class: "org-below", id: nextOrgId()},
staff.length ? h("ul", {class: "org-staff", "aria-label": "Staff positions"}, staff.map((claim) => h("li", {}, officeBox(claim, edges, null)))) : null,
units.length ? h("ul", {class: "org-units", "aria-label": "Line positions"}, units.map((unit) => unitNode(unit, edges))) : null);
const toggle = staff.length || units.length ? folder("chair", "Chair", below) : null;
return [h("div", {class: "org-level org-chair-level"}, chair ? officeBox(chair, edges, toggle) : vacantBox(toggle)), below];
}
function organigram() {
const edges = Organigram.dotted(state.claims, state.tasks);
const {chair, staff, units} = Organigram.chart(state.claims);
const under = h("div", {class: "org-below", id: nextOrgId()}, chairPart(chair, staff, units, edges));
const root = h("div", {class: "org-row org-box org-root"},
h("div", {class: "org-head"}, folder("operator", HUMAN, under), h("span", {class: "org-office"}, icon("bi-person-circle"), h("strong", {}, HUMAN))),
h("span", {class: "muted"}, "assigns every office with a passkey signature"));
const links = s("svg", {class: "org-links", "aria-hidden": "true", focusable: "false"});
const canvas = h("div", {class: "organigram", "data-edges": String(edges.length)}, links, h("div", {class: "org-level"}, root), under);
canvas.orgEdges = edges;
const observer = new ResizeObserver(() => (canvas.isConnected ? drawLinks(canvas) : observer.disconnect()));
observer.observe(canvas);
return h("div", {class: "org-scroll", role: "region", tabindex: "0", "aria-label": "Organigram"}, canvas);
}
function chartBox(base, node) {
if (!node || !node.getClientRects().length) {
return null;
}
const lines = [...dimensions].sort(([a], [b]) => a.localeCompare(b)).map(([dimension, held]) => orgNode(`dimension:${dimension}`, dimension,
groupRow("bi-diagram-2", dimension, held.length, held.length === 1 ? "line" : "lines"),
held.map((claim) => orgNode(claim.office, claim.office, officeRow(claim, claim.line, "Representative"), []))));
const groups = OFFICE_GROUPS.map(([kind, label, title]) => [kind, label, title, claims.filter((entry) => entry.kind === kind)]).filter(([, , , held]) => held.length)
.map(([kind, label, title, held]) => orgNode(`group:${kind}`, label, groupRow(OFFICE_ICONS[kind], label, held.length, kind === "other" ? "" : `${kind}/…`),
held.map((claim) => orgNode(claim.office, claim.office, officeRow(claim, kind === "other" ? claim.office : claim.office.slice(kind.length + 1), title), []))));
const chair = claims.find((entry) => entry.kind === "chair");
const chairNode = orgNode("chair", "Chair", chair ? officeRow(chair, "Chair", "Office") : vacantRow("chair", "Chair"), [...lines, ...groups]);
const root = h("div", {class: "org-row org-root"}, h("span", {class: "org-office"}, icon("bi-person-circle"), h("strong", {}, HUMAN)), h("span", {class: "muted"}, "assigns every office with a passkey signature"));
return h("ul", {class: "org-tree root"}, orgNode("operator", HUMAN, root, [chairNode]));
const found = node.getBoundingClientRect();
return {left: found.left - base.left, top: found.top - base.top, right: found.right - base.left, bottom: found.bottom - base.top};
}
function solidBoxes(canvas, boxOf) {
const units = [...canvas.querySelectorAll(".org-units > .org-unit")].map((unit) => ({box: boxOf(unit.querySelector(".org-unit-box")), positions: [...unit.querySelectorAll(".org-positions > li > .org-box")].map(boxOf).filter(Boolean)}));
return {root: boxOf(canvas.querySelector(".org-root")), chair: boxOf(canvas.querySelector(".org-chair")), staff: [...canvas.querySelectorAll(".org-staff > li > .org-box")].map(boxOf).filter(Boolean), units: units.filter((unit) => unit.box)};
}
function drawLinks(canvas) {
if (!canvas || !canvas.isConnected) {
return;
}
const base = canvas.getBoundingClientRect();
const boxOf = (node) => chartBox(base, node);
const office = (name) => boxOf([...canvas.querySelectorAll(".org-box[data-office]")].find((node) => node.dataset.office === name));
const dashed = (canvas.orgEdges || []).map((edge) => [edge, office(edge.from), office(edge.to)]).filter(([, from, to]) => from && to);
const svg = canvas.querySelector(":scope > .org-links");
svg.setAttribute("width", String(canvas.scrollWidth));
svg.setAttribute("height", String(canvas.scrollHeight));
svg.replaceChildren(...Organigram.solid(solidBoxes(canvas, boxOf)).map((d) => s("path", {class: "org-solid", d})),
...dashed.map(([edge, from, to]) => s("path", {class: "org-dashed", d: Organigram.dashed(from, to), "data-from": edge.from, "data-to": edge.to}, s("title", {}, `${edge.from} to ${edge.to}: ${edge.letters} on ${edge.tasks.join(", ")}`))));
}
function orgLegend() {
const sample = (kind) => s("svg", {class: `org-sample ${kind}`, viewBox: "0 0 28 8", "aria-hidden": "true", focusable: "false"}, s("line", {x1: "1", y1: "4", x2: "27", y2: "4"}));
return h("div", {class: "org-legend", role: "note"},
h("span", {}, sample("solid"), "Line: domain chairs and presidents under the Chair"),
h("span", {}, h("span", {class: "org-swatch", "aria-hidden": "true"}), "Staff: organizers and single offices beside the Chair"),
h("span", {}, sample("dashed"), "Additional superior: A or C on a task in the register"));
}
function drawChart() {
const key = focusKey(hier.chart);
hier.ids = 0;
const old = hier.chart.querySelector(".org-scroll");
const kept = old ? [old.scrollLeft, old.scrollTop] : null;
const count = state.claims.length;
const chart = organigram();
hier.chart.replaceChildren(
h("div", {class: "inbox-head", "data-star-slot": ""}, h("h2", {class: "group-title", id: "org-title"}, "Hierarchy", counter(count)),
h("span", {class: "muted"}, "Formal offices from the council: Operator → Chair → dimensions → lines, plus organizers and presidents"),
h("div", {class: "inbox-head", "data-star-slot": ""}, h("h2", {class: "group-title", id: "org-title"}, "Organigram", counter(count)),
h("span", {class: "muted"}, "Formal offices from the council: Operator, Chair, line and staff positions"),
h("span", {class: "spacer"}),
h("button", {type: "button", class: "btn small soft", "data-focus": "appoint:new", ...named("New office", "New office: give a free office to a session, with a passkey signature"), on: {click: () => officeSheet("appoint", null)}}, icon("bi-person-plus"), "New office")),
chartTree());
orgLegend(),
chart);
if (kept) {
[chart.scrollLeft, chart.scrollTop] = kept;
} else {
centerChair(chart);
}
refocus(hier.chart, key);
}
function centerChair(chart) {
const box = chart.querySelector(".org-chair");
if (box) {
const found = box.getBoundingClientRect();
const frame = chart.getBoundingClientRect();
chart.scrollLeft += found.left + found.width / 2 - (frame.left + frame.width / 2);
}
}
+1 -1
View File
@@ -153,7 +153,7 @@
Panels.panel("agents/swimlane", "Agents: Swimlane", () => swimlane());
Panels.panel("agents/3d", "Agents: 3D", () => home3d("agents"), "3d");
Panels.panel("agents/tree", "Agents: spawn tree", () => h("ul", {class: "spawn-tree root"}, spawnItem(spawnTree())));
Panels.panel("agents/hierarchy", "Agents: hierarchy", () => chartTree());
Panels.panel("agents/hierarchy", "Agents: organigram", () => organigram());
Panels.panel("artifacts/orbit", "Artifacts: Orbit", () => homeArt("orbit"));
Panels.panel("artifacts/chord", "Artifacts: Chord", () => homeArt("chord"));
Panels.panel("artifacts/swimlane", "Artifacts: Swimlane", () => homeArt("swimlane"));
+40 -13
View File
@@ -1,19 +1,46 @@
.hierarchy-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
@media (max-width: 960px) { .hierarchy-body { grid-template-columns: minmax(0, 1fr); } }
.org-chart { min-width: 0; }
.org-chart .inbox-head { flex-wrap: wrap; }
.org-tree { display: grid; gap: 4px; margin: 0; padding: 0 0 0 16px; list-style: none; border-left: 1px solid var(--line); margin-left: 14px; }
.org-tree.root { margin-left: 0; padding-left: 0; border-left: 0; }
.org-tree[hidden] { display: none; }
.org-line { display: flex; align-items: flex-start; gap: 4px; }
.org-toggle { margin-top: 3px; }
.org-gap { flex: none; width: 30px; }
.org-row { display: flex; flex: 1; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-width: 0; padding: 5px 8px; border-radius: 8px; }
.org-row:hover { background: var(--hover); }
.org-row.vacant { border: 1px dashed var(--line-strong); }
.org-row.group .org-office { color: var(--muted); }
.org-office, .org-holder { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.org-work { flex: 1 1 140px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-actions { display: inline-flex; gap: 2px; margin-left: auto; }
.org-legend { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0 0 10px; color: var(--muted); font-size: var(--fs-sm); }
.org-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.org-sample { flex: none; width: 28px; height: 8px; }
.org-sample line { stroke: var(--line-strong); stroke-width: 2; }
.org-sample.dashed line { stroke: var(--violet); stroke-dasharray: 5 4; }
.org-swatch { flex: none; width: 18px; height: 12px; border: 1px solid color-mix(in srgb, var(--info) 55%, var(--line-strong)); border-radius: 4px; background: color-mix(in srgb, var(--info) 12%, var(--panel)); }
.org-scroll { max-width: 100%; overflow: auto; overscroll-behavior-x: contain; border-radius: var(--radius-sm); }
.organigram { --org-box: 236px; position: relative; display: flex; flex-direction: column; align-items: center; width: max-content; min-width: 100%; padding: 8px 56px 18px 12px; }
.org-links { position: absolute; top: 0; left: 0; z-index: 0; overflow: visible; pointer-events: none; }
.org-links .org-solid { fill: none; stroke: var(--line-strong); stroke-width: 1.5; }
.org-links .org-dashed { fill: none; stroke: var(--violet); stroke-width: 1.5; stroke-dasharray: 6 5; }
.org-level { display: flex; justify-content: center; }
.org-chair-level { margin-top: 30px; }
.org-below { display: flex; flex-direction: column; align-items: center; align-self: stretch; }
.org-below[hidden], .org-positions[hidden] { display: none; }
.org-box { position: relative; z-index: 1; display: grid; gap: 4px; width: var(--org-box); min-width: 0; padding: 7px 9px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--panel); box-shadow: var(--shadow); }
.org-box:hover { background: color-mix(in srgb, var(--hover) 60%, var(--panel)); }
.org-box.org-chair { border-color: color-mix(in srgb, var(--accent) 60%, var(--line-strong)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent), var(--shadow); }
.org-box.vacant { border-style: dashed; }
.org-box[data-position="staff"] { border-color: color-mix(in srgb, var(--info) 55%, var(--line-strong)); background: color-mix(in srgb, var(--info) 12%, var(--panel)); }
.org-box.org-root { width: auto; max-width: 300px; }
.org-unit-box { background: color-mix(in srgb, var(--neutral-soft) 70%, var(--panel)); }
.org-unit-box .org-office { color: var(--muted); }
.org-head { display: flex; align-items: center; gap: 4px 6px; min-width: 0; }
.org-office { display: inline-flex; flex: 1; align-items: center; gap: 6px; min-width: 0; }
.org-name { display: grid; min-width: 0; line-height: var(--lh-tight); }
.org-name strong, .org-unit-box strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-title { color: var(--muted); font-size: var(--fs-2xs); font-weight: 650; letter-spacing: .04em; text-transform: uppercase; }
.org-who { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.org-holder { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.org-work { min-width: 0; overflow: hidden; font-size: var(--fs-sm); text-overflow: ellipsis; white-space: nowrap; }
.org-dotted { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--violet); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.org-actions { display: flex; justify-content: flex-end; gap: 2px; }
.org-staff { display: grid; grid-template-columns: 1fr 1fr; grid-auto-flow: row dense; gap: 10px calc(var(--org-box) + 48px); align-self: stretch; margin: 22px 0 0; padding: 0; list-style: none; }
.org-staff > li:nth-child(odd) { grid-column: 2; justify-self: start; }
.org-staff > li:nth-child(even) { grid-column: 1; justify-self: end; }
.org-units { display: flex; align-items: flex-start; justify-content: center; gap: 22px; margin: 40px 0 0; padding: 0; list-style: none; }
.org-unit { display: grid; justify-items: start; }
.org-positions { display: grid; gap: 10px; margin: 12px 0 0; padding: 0 0 0 32px; list-style: none; }
.agent-order .order-list li { gap: 8px; padding: 6px 8px; }
.agent-order .order-list .linkish { min-width: 0; }
.agent-order .grip { flex: none; color: var(--muted); }
+160
View File
@@ -0,0 +1,160 @@
from __future__ import annotations
import json
import os
import shutil
import sys
import time
import unittest
from pathlib import Path
HERE = Path(__file__).resolve().parent
sys.path[:0] = [str(HERE.parent), str(HERE)]
import test_orchestrator_e2e as base
from hub_case import HubCase
from hub_support import iso
OUT = Path(os.environ.get("E2E_OUT", "/tmp/organigram-shots"))
CHART = """(async () => {@HELPERS@
await screenShown(8000);
const canvas = await until(() => {
const found = document.querySelector("#main .organigram");
return found && found.querySelectorAll(".org-links path.org-dashed").length >= 3 ? found : null;
}, 8000);
if (!canvas) {
return {error: text(document.getElementById("main"))};
}
await sleep(300);
canvas.closest(".org-chart").scrollIntoView({block: "start"});
const scroll = canvas.closest(".org-scroll");
const rect = (node) => node.getBoundingClientRect();
const chair = rect(document.querySelector('#main .org-box[data-office="chair"]'));
const staff = all("#main .org-staff .org-box").map((node) => [node, rect(node)]);
const units = all("#main .org-units > .org-unit");
const side = (box) => (box.right <= chair.left ? "left" : box.left >= chair.right ? "right" : "under");
const icons = all("#main svg.bi").map((svg) => svg.parentElement).filter((owner) => !text(owner) && !(owner.getAttribute("title") && owner.getAttribute("aria-label")));
return {
title: text(document.getElementById("org-title")),
offices: all("#main .org-chart .org-row[data-office]").map((row) => [row.dataset.office, row.dataset.position, text(row.querySelector(".org-holder"))]),
staff: staff.map(([node, box]) => [node.dataset.office, side(box)]),
staffBelowChair: staff.every(([, box]) => box.top > chair.bottom),
unitsBelowStaff: units.every((unit) => staff.every(([, box]) => rect(unit).top > box.bottom)),
units: units.map((unit) => [unit.dataset.node, all(".org-positions .org-box", unit).map((node) => node.dataset.office)]),
dashed: all("#main .org-links path.org-dashed").map((path) => [path.dataset.from, path.dataset.to, getComputedStyle(path).strokeDasharray !== "none"]),
solid: all("#main .org-links path.org-solid").length,
also: all("#main .org-dotted").map((node) => [node.closest(".org-box").dataset.office, text(node)]),
toggles: all("#main .org-toggle").map(name),
scroll: {inner: scroll.scrollWidth > scroll.clientWidth + 1, overflow: getComputedStyle(scroll).overflowX},
chairSeen: chair.left >= rect(scroll).left - 1 && chair.right <= rect(scroll).right + 1,
wide: document.documentElement.scrollWidth > window.innerWidth + 1,
unlabelled: icons.map((owner) => owner.outerHTML.slice(0, 120)),
};
})()""".replace("@HELPERS@", base.HELPERS)
FOLD = """(async () => {@HELPERS@
const toggle = all("#main .org-toggle").find((button) => name(button) === "Collapse: identity");
toggle.click();
await sleep(300);
return {label: name(toggle), dashed: all("#main .org-links path.org-dashed").map((path) => `${path.dataset.from} > ${path.dataset.to}`), seen: all("#main .org-box[data-office]").filter((node) => node.offsetParent !== null).map((node) => node.dataset.office)};
})()""".replace("@HELPERS@", base.HELPERS)
UNFOLD = """(async () => {@HELPERS@
const toggle = all("#main .org-toggle").find((button) => name(button) === "Expand: identity");
toggle.click();
await sleep(300);
return {label: name(toggle), dashed: all("#main .org-links path.org-dashed").map((path) => `${path.dataset.from} > ${path.dataset.to}`)};
})()""".replace("@HELPERS@", base.HELPERS)
UNITS = """(async () => {@HELPERS@
const unit = document.querySelector('#main .org-unit[data-node="group:work"]');
const scroll = unit.closest(".org-scroll");
const before = scroll.scrollLeft;
unit.scrollIntoView({block: "start", inline: "start"});
await sleep(300);
const box = unit.querySelector(".org-unit-box").getBoundingClientRect();
const frame = scroll.getBoundingClientRect();
return {moved: scroll.scrollLeft > before, seen: box.left >= frame.left - 1 && box.right <= frame.right + 1, wide: document.documentElement.scrollWidth > window.innerWidth + 1, page: window.scrollX};
})()""".replace("@HELPERS@", base.HELPERS)
OFFICES = [
["chair", "chair", "Skills"],
["cluster/web", "staff", "Main"],
["stack-architecture", "staff", "Production"],
["identity/ldap", "line", "Experiment"],
["identity/oidc", "line", "Stage"],
["network/dns", "line", "Stage"],
["work/s2", "line", "Stage"],
["work/s3", "line", "Experiment"],
]
DASHED = [["identity/oidc", "identity/ldap", True], ["identity/oidc", "work/s3", True], ["stack-architecture", "network/dns", True]]
@unittest.skipUnless(shutil.which(os.environ.get("CHROMIUM", "chromium")), "no Chromium")
class TestOrganigramE2E(HubCase):
drive = base.TestOrchestratorE2E.drive
def setUp(self):
super().setUp()
OUT.mkdir(parents=True, exist_ok=True)
now = time.time()
def held(office: str, session: str, name: str, work: str) -> dict:
return {"office": office, "session": session, "runtime": "claude", "name": name, "since": iso(now - 7200), "beat": now - 30, "work": work}
self.write_council({
"chair/claim.json": held("chair", "s1", "Skills session", "allocate"),
"identity/oidc/claim.json": held("identity/oidc", "s2", "Stage", "oidc line"),
"network/dns/claim.json": held("network/dns", "s2", "Stage", "work/dns"),
"work/s2/claim.json": held("work/s2", "s2", "Stage", "x"),
"identity/ldap/claim.json": held("identity/ldap", "s3", "Experiment", "work/ldap"),
"work/s3/claim.json": held("work/s3", "s3", "Experiment", "x"),
"cluster/web/claim.json": held("cluster/web", "s4", "Main", "web cluster"),
"stack-architecture/claim.json": held("stack-architecture", "s5", "Production", "stack"),
"rasci.json": {
"work/ldap": {"title": "LDAP sync", "status": "running", "worker": "Experiment", "roles": {"Experiment": "R", "Stage": "A"}},
"work/dns": {"title": "DNS zones", "status": "running", "worker": "Stage", "roles": {"Stage": "R", "Production": "C"}},
"work/s3": {"title": "Presidency", "status": "queued", "worker": "Experiment", "roles": {"Experiment": "R", "Stage": "C", "Operator": "A"}},
"work/web": {"title": "Web cluster", "status": "running", "worker": "Main", "roles": {"Main": "RA", "Skills session": "C"}},
"work/old": {"title": "Old", "status": "done", "worker": "Production", "roles": {"Production": "R", "Main": "A"}},
},
})
self.base = f"http://{self.host}/"
def test_chromium_draws_the_organigram_with_staff_beside_the_chair_and_dashed_superiors_at_three_widths(self):
steps = []
for width, height in base.WIDTHS:
steps.append({"width": width, "height": height, "url": f"{self.base}?{width}#agents/hierarchy", "wait": 1200, "probe": CHART, "shot": str(OUT / f"chromium-{width}-organigram.png")})
if width == 1366:
steps.append({"width": width, "height": height, "url": None, "wait": 0, "probe": FOLD, "shot": str(OUT / f"chromium-{width}-organigram-folded.png")})
steps.append({"width": width, "height": height, "url": None, "wait": 0, "probe": UNFOLD, "shot": None})
if width == 390:
steps.append({"width": width, "height": height, "url": None, "wait": 0, "probe": UNITS, "shot": str(OUT / f"chromium-{width}-organigram-units.png")})
data = self.drive(steps, None)
(OUT / "chromium-organigram.json").write_text(json.dumps(data, indent=1), encoding="utf-8")
self.assertEqual(data["errors"], [])
results = iter(data["results"])
for width, _ in base.WIDTHS:
chart = next(results)
with self.subTest(width=width):
self.assertNotIn("error", chart, chart)
self.assertTrue(chart["title"].startswith("Organigram"), chart["title"])
self.assertEqual(chart["offices"], OFFICES)
self.assertEqual(chart["staff"], [["cluster/web", "right"], ["stack-architecture", "left"]])
self.assertTrue(chart["staffBelowChair"] and chart["unitsBelowStaff"], chart)
self.assertEqual(chart["units"], [["dimension:identity", ["identity/ldap", "identity/oidc"]], ["dimension:network", ["network/dns"]], ["group:work", ["work/s2", "work/s3"]]])
self.assertEqual(chart["dashed"], DASHED)
self.assertEqual(chart["solid"], 16)
self.assertEqual(chart["also"], [["identity/ldap", "Also under identity/oidc (A)"], ["network/dns", "Also under stack-architecture (C)"], ["work/s3", "Also under identity/oidc (C)"]])
self.assertEqual(chart["toggles"], ["Collapse: Operator", "Collapse: Chair", "Collapse: identity", "Collapse: network", "Collapse: Presidents"])
self.assertEqual((chart["unlabelled"], chart["wide"], chart["scroll"]["overflow"], chart["chairSeen"]), ([], False, "auto", True))
if width == 390:
self.assertTrue(chart["scroll"]["inner"], "the organigram does not scroll inside its container")
if width == 1366:
folded, unfolded = next(results), next(results)
self.assertEqual((folded["label"], folded["dashed"]), ("Expand: identity", ["stack-architecture > network/dns"]))
self.assertNotIn("identity/oidc", folded["seen"])
self.assertEqual((unfolded["label"], len(unfolded["dashed"])), ("Collapse: identity", 3))
if width == 390:
moved = next(results)
self.assertEqual((moved["moved"], moved["seen"], moved["wide"], moved["page"]), (True, True, False, 0), moved)
if __name__ == "__main__":
unittest.main()
+127
View File
@@ -0,0 +1,127 @@
from __future__ import annotations
import json
import shutil
import subprocess
import unittest
from pathlib import Path
ORGANIGRAM = Path(__file__).resolve().parent.parent / "orchestrator" / "templates" / "organigram.js"
PROBE = """
const O = require(process.argv[1]);
const claim = (office, kind, agent, fields) => {
const [dimension, line] = kind === "line" ? office.split("/") : ["", ""];
return {office, kind, dimension, line, agent, session: agent ? `s-${agent}` : "s9", work: "-", beat: null, ...fields};
};
const claims = [
claim("work/s3", "work", "Experiment"),
claim("stack-architecture", "other", "Production"),
claim("identity/oidc", "line", "Stage"),
claim("chair", "chair", "Skills"),
claim("cluster/web", "cluster", "Main"),
claim("network/dns", "line", "Stage"),
claim("identity/ldap", "line", "Experiment", {work: "work/ldap"}),
claim("work/s2", "work", "Stage"),
claim("work/s9", "work", ""),
];
const task = (name, roles, fields) => ({task: name, ended: false, worker: "-", roles, ...fields});
const tasks = [
task("work/ldap", {Experiment: "R", Stage: "A"}),
task("work/dns", {Stage: "R", Production: "C", Experiment: "I"}),
task("work/web", {Main: "RA", Skills: "C"}),
task("work/old", {Production: "R", Main: "A"}, {ended: true}),
task("work/s3", {Experiment: "R", Stage: "C", Operator: "A"}),
task("work/ldap2", {Experiment: "R", Stage: "AC"}),
task("work/worker", {Main: "C"}, {worker: "Production"}),
task("work/support", {Stage: "R", Main: "S", Production: "I"}),
task("queue/gate-1", {}),
];
const chart = O.chart(claims);
const box = (left, top, width, height) => ({left, top, right: left + width, bottom: top + height});
const unit = (left) => ({box: box(left, 300, 200, 40), positions: [box(left + 30, 360, 200, 60), box(left + 30, 440, 200, 60)]});
console.log(JSON.stringify({
positions: Object.fromEntries(claims.map((entry) => [entry.office, O.position(entry)])),
unknown: O.position(claim("odd", "mystery", "X")),
chart: {
chair: chart.chair && chart.chair.office,
staff: chart.staff.map((entry) => entry.office),
units: chart.units.map((entry) => [entry.id, entry.kind, entry.label, entry.positions.map((position) => position.office)]),
},
vacant: O.chart(claims.filter((entry) => entry.kind !== "chair")).chair,
edges: O.dotted(claims, tasks),
quiet: O.dotted(claims, tasks.map((entry) => ({...entry, ended: true}))),
solid: O.solid({root: box(400, 0, 200, 50), chair: box(400, 90, 200, 80), staff: [box(560, 200, 200, 60), box(240, 200, 200, 60)], units: [unit(100), unit(700)]}),
lonely: O.solid({root: box(400, 0, 200, 50), chair: box(400, 90, 200, 80), staff: [], units: []}),
below: O.dashed(box(0, 0, 100, 40), box(300, 200, 100, 40)),
column: O.dashed(box(0, 0, 100, 40), box(0, 200, 100, 40)),
beside: O.dashed(box(300, 0, 100, 40), box(0, 20, 100, 40)),
}));
"""
@unittest.skipUnless(shutil.which("node"), "no node")
class TestOrganigram(unittest.TestCase):
@classmethod
def setUpClass(cls):
done = subprocess.run(["node", "-e", PROBE, str(ORGANIGRAM)], capture_output=True, text=True, timeout=60, check=True)
cls.data = json.loads(done.stdout)
def test_domain_chairs_and_presidents_stand_in_line_and_organizers_and_single_offices_are_staff(self):
self.assertEqual(self.data["positions"], {
"work/s3": "line", "stack-architecture": "staff", "identity/oidc": "line", "chair": "chair", "cluster/web": "staff",
"network/dns": "line", "identity/ldap": "line", "work/s2": "line", "work/s9": "line",
})
self.assertEqual(self.data["unknown"], "staff")
def test_the_chart_puts_the_dimensions_by_name_then_the_presidents_under_the_chair_and_the_staff_beside_it(self):
self.assertEqual(self.data["chart"], {
"chair": "chair",
"staff": ["cluster/web", "stack-architecture"],
"units": [
["dimension:identity", "dimension", "identity", ["identity/ldap", "identity/oidc"]],
["dimension:network", "dimension", "network", ["network/dns"]],
["group:work", "work", "Presidents", ["work/s2", "work/s3", "work/s9"]],
],
})
self.assertIsNone(self.data["vacant"])
def test_an_office_holder_named_a_or_c_on_an_open_task_becomes_a_dashed_superior(self):
self.assertEqual(self.data["edges"], [
{"from": "cluster/web", "to": "stack-architecture", "letters": "C", "tasks": ["work/worker"]},
{"from": "identity/oidc", "to": "identity/ldap", "letters": "AC", "tasks": ["work/ldap", "work/ldap2"]},
{"from": "identity/oidc", "to": "work/s3", "letters": "C", "tasks": ["work/s3"]},
{"from": "stack-architecture", "to": "identity/oidc", "letters": "C", "tasks": ["work/dns"]},
])
def test_ended_tasks_the_chair_s_own_line_and_parties_without_an_office_draw_no_dashed_line(self):
self.assertEqual(self.data["quiet"], [])
drawn = {(edge["from"], edge["to"]) for edge in self.data["edges"]}
self.assertFalse({edge for edge in drawn if edge[0] == "chair" or "Operator" in edge})
self.assertNotIn(("cluster/web", "identity/oidc"), drawn)
def test_the_solid_lines_join_root_chair_staff_rail_and_combs(self):
self.assertEqual(self.data["solid"], [
"M 500 50 V 70 H 500 V 90",
"M 500 170 L 500 282",
"M 500 230 L 560 230",
"M 500 230 L 440 230",
"M 200 282 L 800 282",
"M 200 282 L 200 300",
"M 800 282 L 800 300",
"M 118 340 L 118 470",
"M 118 390 L 130 390",
"M 118 470 L 130 470",
"M 718 340 L 718 470",
"M 718 390 L 730 390",
"M 718 470 L 730 470",
])
self.assertEqual(self.data["lonely"], ["M 500 50 V 70 H 500 V 90"])
def test_a_dashed_line_leaves_the_facing_edges_and_rounds_a_shared_column_on_the_right(self):
self.assertEqual(self.data["below"], "M 50 40 C 50 120 350 120 350 200")
self.assertEqual(self.data["column"], "M 100 20 C 136 20 136 220 100 220")
self.assertEqual(self.data["beside"], "M 300 20 C 200 20 200 40 100 40")
if __name__ == "__main__":
unittest.main()