From 97a95d02e6580bdb53c41b958691c8dd30db3429 Mon Sep 17 00:00:00 2001 From: Jay Leimer Date: Sun, 6 Sep 2026 19:07:28 +0200 Subject: [PATCH] fix role tabs plus governor tab create plus delegation plus retrieval --- docs/architecture.md | 2 +- src/agents.js | 13 +- src/prompts.js | 185 ++++++++++++++++++++++++++++- test/agents.test.js | 14 +-- test/m2-placement-boundary.test.js | 166 +++++++++++++++++++++++++- test/m2-prompt-policy.test.js | 21 ++-- test/m2-topology-hardening.test.js | 34 ++++++ test/plugin.test.js | 9 +- 8 files changed, 411 insertions(+), 33 deletions(-) diff --git a/docs/architecture.md b/docs/architecture.md index d9130f3..7feb0a8 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -66,7 +66,7 @@ Temporary details stay temporary and small: session context ends with the sessio ## Pane and tab layout -Pane layout policy (single normative policy, same wording as prompts): Four-pane cap: at most four panes per tab including the caller pane. Reuse first within the four-pane cap per tab. Never split when the filtered count is already four; overflow to a new tab instead. Overflow to a new tab with indexed role labels when the cap binds. Grouped by role with indexed labels (Sheepdog, sheep-1, sheep-2, shearer-low-1, grazer-1); tabs keep their existing labels. Reuse the matching pane when found; split only when no reusable pane exists and the cap permits. Reuse is preferred over clutter. Never derive IDs from sidebar order or examples; parse them from JSON responses. The pane labeled Dev (Developer Terminal) is excluded from every scan plus split plus placement plus rename plus close plus reuse. Never count it toward the four-pane cap, never list it as a reuse candidate, never split from it or into it, never place a worker there, never rename it, never close it, and never reuse it for overflow. Filter it during scan by terminal_title plus terminal_title_stripped plus label before counting plus reusing; when only the Dev pane would satisfy reuse, treat reuse as absent and either split elsewhere within cap or overflow to a new tab or report STOP with preserved state. Never create a workspace to evade the cap. Never touch the Dev pane in any tab. Start in the calling pane and never rely on another client focused pane. Six-step placement is reuse-first plus evidence-only with new-tab overflow. Dynamic placement follows the same single normative pane policy with new-tab overflow and no separate rulebook. Shepherd and sheepdog hold herdr tab create for per-tab overflow with indexed role labels; governor keeps single-pane scan plus placement plus rename only and leaves gain no pane plus tab plus rename commands. +Pane layout policy (single normative policy, same wording as prompts): Four-pane cap: at most four panes per tab including the caller pane. Reuse first within the four-pane cap per tab. Never split when the filtered count is already four; overflow to a new tab instead. Overflow to a new tab with indexed role labels when the cap binds. Grouped by role with indexed labels (Sheepdog, sheep-1, sheep-2, shearer-low-1, grazer-1); tabs keep their existing labels. Reuse the matching pane when found; split only when no reusable pane exists and the cap permits. Reuse is preferred over clutter. Never derive IDs from sidebar order or examples; parse them from JSON responses. The pane labeled Dev (Developer Terminal) is excluded from every scan plus split plus placement plus rename plus close plus reuse. Never count it toward the four-pane cap, never list it as a reuse candidate, never split from it or into it, never place a worker there, never rename it, never close it, and never reuse it for overflow. Filter it during scan by terminal_title plus terminal_title_stripped plus label before counting plus reusing; when only the Dev pane would satisfy reuse, treat reuse as absent and either split elsewhere within cap or overflow to a new tab or report STOP with preserved state. Never create a workspace to evade the cap. Never touch the Dev pane in any tab. Start in the calling pane and never rely on another client focused pane. Six-step placement is reuse-first plus evidence-only with new-tab overflow. Dynamic placement follows the same single normative pane policy with new-tab overflow and no separate rulebook. Shepherd, shepherd-governor, and sheepdog hold herdr tab create for per-tab overflow with indexed role labels; governor never closes flock panes and leaves gain no pane plus tab plus rename commands. Dedicated role tabs are titled at creation via tab create label and never renamed. Never place worker panes on the shepherd caller tab. Sheepdog stays alone in its own tab titled Sheepdog plus descriptor with no flock workers. Grazer role tabs hold at most four panes in quadrant geometry with overflow to indexed grazers tabs. Sheep role tabs hold at most four panes with overflow to indexed sheep tabs. Shearer role tabs hold at most two panes side by side with overflow to indexed shearers tabs. Four-pane quadrant geometry is split right once then split each side down once parsing each new pane ID from JSON. Never mix roles within a role tab. ## Docs navigation diff --git a/src/agents.js b/src/agents.js index ef1c322..df989f8 100644 --- a/src/agents.js +++ b/src/agents.js @@ -326,8 +326,16 @@ const GOVERNOR_SEND_KEYS_CTRL_C_ALLOWS = { // pane IDs are opaque and labels are absent from scan plus split plus close // command strings, while a `*Dev*` glob would overmatch legitimate // `--cwd C:\Dev\...` values, so no such glob is added; the prompt plus docs -// architecture tab section exclusion stays primary with per-tab cap plus -// new-tab overflow plus never touch Dev in any tab; see docs residual. + // architecture tab section exclusion stays primary with per-tab cap plus + // new-tab overflow plus never touch Dev in any tab; see docs residual. + // Role-tab layout: dedicated tabs titled at creation via tab create label + // (`Sheepdog - `, `grazers`, `sheep`, `shearers` plus indexed + // overflow `grazers-2` etc.), never renamed (tab rename stays denied); + // shepherd caller tab never hosts worker panes; sheepdog stays alone; + // grazers plus sheep up to four panes in quadrant geometry (split right + // once then each side down once, parsing each ID from JSON); shearers up + // to two panes side by side; per-role overflow to new indexed role tabs; + // roles never mix within a role tab. const SHEPHERD_PANE_ALLOWS = { "herdr tab list*": "allow", "herdr tab create*": "allow", @@ -337,6 +345,7 @@ const SHEPHERD_PANE_ALLOWS = { }; const GOVERNOR_PANE_ALLOWS = { "herdr tab list*": "allow", + "herdr tab create*": "allow", "herdr pane get*": "allow", "herdr pane rename*": "allow", "herdr agent rename*": "allow", diff --git a/src/prompts.js b/src/prompts.js index f1b29e0..2b07e30 100644 --- a/src/prompts.js +++ b/src/prompts.js @@ -4,9 +4,37 @@ // Every spawning role carries the same shared sentences; role-specific // ownership plus startup destinations differ per role. Leaves stay unchanged. // Spawn plus response plus state matrices stay intact with no new spawn targets. -// Pre-create default stays minimal via reuse of the current pane. +// Role tabs are created lazily on first need and reused thereafter. export const PANE_CAP = 4; export const DEV_PANE_LABELS = Object.freeze(["Dev", "Developer Terminal"]); +// Dedicated role-tab layout: per-role tabs titled at creation, never renamed. +// Caps per role tab stay within the hard four-pane cap: grazers 4, sheep 4, +// shearers 2 side by side, sheepdog alone. The shepherd caller tab is sacred +// and never hosts worker panes. +export const ROLE_TAB_CAPS = Object.freeze({ + sheepdog: 1, + grazer: 4, + sheep: 4, + "shearer-low": 2, + "shearer-medium": 2, +}); +export const ROLE_TAB_BASE_LABELS = Object.freeze({ + sheepdog: "Sheepdog", + grazer: "grazers", + sheep: "sheep", + "shearer-low": "shearers", + "shearer-medium": "shearers", +}); +export const ROLE_TAB_POLICY_SENTENCES = Object.freeze([ + "dedicated role tabs are titled at creation via tab create label and never renamed.", + "Never place worker panes on the shepherd caller tab", + "Sheepdog stays alone in its own tab titled Sheepdog plus descriptor with no flock workers.", + "Grazer role tabs hold at most four panes in quadrant geometry with overflow to indexed grazers tabs.", + "Sheep role tabs hold at most four panes with overflow to indexed sheep tabs.", + "Shearer role tabs hold at most two panes side by side with overflow to indexed shearers tabs.", + "Four-pane quadrant geometry is split right once then split each side down once parsing each new pane ID from JSON", + "Never mix roles within a role tab.", +]); export const PANE_POLICY_SHARED_SENTENCES = Object.freeze([ "at most four panes per tab including the caller pane", "Reuse first within the four-pane cap per tab", @@ -33,14 +61,17 @@ export const PANE_POLICY_SHARED_SENTENCES = Object.freeze([ export const PANE_POLICY_SHARED_PARAGRAPH = String.raw` Pane layout policy (single normative policy, same wording as docs architecture tab section): Four-pane cap: at most four panes per tab including the caller pane. Reuse first within the four-pane cap per tab. Never split when the filtered count is already four; overflow to a new tab instead. Overflow to a new tab with indexed role labels when the cap binds. Grouped by role with indexed labels (Sheepdog, sheep-1, sheep-2, shearer-low-1, grazer-1); tabs keep their existing labels. Reuse the matching pane when found; split only when no reusable pane exists and the cap permits. Reuse is preferred over clutter: reuse a capacity-available managed pane for the same role before splitting. Never derive IDs from sidebar order or examples; parse them from JSON responses. The pane labeled Dev (Developer Terminal) is excluded from every scan plus split plus placement plus rename plus close plus reuse. Never count it toward the four-pane cap, never list it as a reuse candidate, never split from it or into it, never place a worker there, never rename it, never close it, and never reuse it for overflow. Filter it during scan by terminal_title plus terminal_title_stripped plus label before counting plus reusing; when only the Dev pane would satisfy reuse, treat reuse as absent and either split elsewhere within cap or overflow to a new tab or report STOP with preserved state. Never create a workspace to evade the cap. Never touch the Dev pane in any tab. Start in the calling pane and never rely on another client focused pane. If any primitive below is missing, reuse the current pane via --pane plus --current and report STOP naming the missing capability with preserved state. Pre-create default stays minimal: reuse the current pane via --pane plus --current when primitives are missing. On finish, reuse the pane for the next same-role assignment after confirming idle plus done. Six-step placement is reuse-first plus evidence-only with new-tab overflow. Dynamic placement follows the same single normative pane policy with new-tab overflow and no separate rulebook. `.trim(); +export const ROLE_TAB_POLICY_PARAGRAPH = String.raw` +Role-tab layout policy (single normative role-tab policy, same wording as docs architecture tab section): dedicated role tabs are titled at creation via tab create label and never renamed. Never place worker panes on the shepherd caller tab: scan it only for caller context, then place every worker in its role tab. Sheepdog stays alone in its own tab titled Sheepdog plus descriptor with no flock workers. Grazer role tabs hold at most four panes in quadrant geometry with overflow to indexed grazers tabs. Sheep role tabs hold at most four panes with overflow to indexed sheep tabs. Shearer role tabs hold at most two panes side by side with overflow to indexed shearers tabs. Four-pane quadrant geometry is split right once then split each side down once parsing each new pane ID from JSON; two-pane shearer geometry is split right once. Never mix roles within a role tab. Reuse first within the per-role cap after confirming idle plus done; split only when no reusable same-role pane exists and the per-role cap permits; overflow to a new indexed role tab when the per-role cap binds. Dev exclusion plus evidence-only ID parsing plus no focused-pane reliance apply in every role tab. +`.trim(); export const SHEPHERD_PANE_OWNERSHIP_PARAGRAPH = String.raw` -Shepherd pane ownership plus startup: shepherd manages its single Sheepdog pane scan plus placement plus rename plus tab create only and never closes; starts its grazer in a sibling pane of the current tab with overflow to a new tab with indexed role labels when the cap binds; leaves gain no pane plus tab plus rename commands and stay unchanged. +Shepherd pane ownership plus startup: shepherd manages scan plus placement plus rename plus tab create and never closes; starts its grazers in dedicated grazers role tabs and never places panes on the calling tab; sheepdog stays alone in its own tab; leaves gain no pane plus tab plus rename commands and stay unchanged. `.trim(); export const GOVERNOR_PANE_OWNERSHIP_PARAGRAPH = String.raw` -Governor pane ownership plus startup: shepherd-governor manages its single Sheepdog pane scan plus placement plus rename only and never closes flock panes; starts its sheepdog in a dedicated sibling Sheepdog pane of the current tab; leaves gain no pane plus tab plus rename commands and stay unchanged. +Governor pane ownership plus startup: shepherd-governor manages scan plus placement plus rename plus tab create and never closes flock panes; starts its sheepdog alone in its own tab titled Sheepdog plus descriptor and starts supplementary grazers in dedicated grazers role tabs; never places panes on the calling tab; leaves gain no pane plus tab plus rename commands and stay unchanged. `.trim(); export const SHEEPDOG_PANE_OWNERSHIP_PARAGRAPH = String.raw` -Sheepdog pane ownership plus startup plus dynamic placement: sheepdog manages flock panes scan plus placement plus rename plus close plus tab create up to the per-tab cap; only the creator may rename plus close its panes and only after commits are integrated or otherwise preserved and the worktree is clean; starts in its own Sheepdog pane and starts flock workers in sibling flock panes of the current tab with overflow to a new tab with indexed role labels when the cap binds grouped by role with indexed labels; startup destinations for grazer plus sheep plus shearer-low plus shearer-medium worker categories stay within the four-pane cap per tab with Dev excluded in any tab and pre-create default minimal; six-step placement is reuse-first plus evidence-only with new-tab overflow with cap check plus reuse check plus split plus rename plus tab create plus start; on cap go to a new tab with indexed role labels and never split a fifth pane; reuse capacity-available managed panes first within the cap and reuse the pane on finish after confirming idle plus done; never create a workspace to evade the cap and never touch the Dev pane in any tab. +Sheepdog pane ownership plus startup plus dynamic placement: sheepdog manages flock panes scan plus placement plus rename plus close plus tab create across dedicated role tabs; only the creator may rename plus close its panes and only after commits are integrated or otherwise preserved and the worktree is clean; stays alone in its own tab titled Sheepdog plus descriptor with no flock workers; starts grazers in grazers tabs up to four panes in quadrant geometry and sheep in sheep tabs up to four panes and shearers in shearers tabs up to two panes side by side with overflow to indexed role tabs when the per-role cap binds; never places panes on the shepherd calling tab and never mixes roles within a role tab; startup destinations for grazer plus sheep plus shearer-low plus shearer-medium worker categories stay within the per-role cap with Dev excluded in any tab and role tabs created lazily on first need; six-step placement is reuse-first plus evidence-only with new-tab overflow with cap check plus reuse check plus split plus rename plus tab create plus start; on cap go to a new indexed role tab and never split beyond the per-role cap; reuse capacity-available managed panes first within the cap and reuse the pane on finish after confirming idle plus done; never create a workspace to evade the cap and never touch the Dev pane in any tab. `.trim(); export const SHEPHERD_PROMPT = String.raw` You are shepherd, the planning authority of the flock. You research the user's goal through grazer workers and present an implementation-ready plan. You never implement, integrate, or deliver; execution and final delivery belong to shepherd-governor after the user approves your plan by selecting it. @@ -87,6 +118,8 @@ Shepherd ownership and semantic synchronization: claim a validated target lifecy ${PANE_POLICY_SHARED_PARAGRAPH} +${ROLE_TAB_POLICY_PARAGRAPH} + ${SHEPHERD_PANE_OWNERSHIP_PARAGRAPH} `.trim(); @@ -125,6 +158,8 @@ herdr agent start --kind opencode --pane -- --agent sheepdog Use grazer for supplementary research and sheepdog for execution squads. Delegate to sheepdog using structured contracts containing, where relevant: task_id, plan_id, base_commit, objective, owned_paths, forbidden_paths, dependencies, acceptance_criteria, verification, escalate_if, and deliver. Resolve global ambiguity before delegating. Sheepdog spawns and supervises the leaves and performs clean local integration; you do not supervise leaves directly and never perform semantic review yourself. Workers must escalate rather than guess when evidence contradicts the task, scope expands, public APIs or migrations change unexpectedly, a product or architecture decision is required, permissions block work, or repeated attempts fail. +Construct delegation text content-safe: never carry raw separator characters even inside quotes, because Bash matchers deny any command containing them after the prompt allow and the prompt then fails closed; quote identifiers and split or rephrase delivery instead of embedding separators. For large contracts, write a Markdown brief or handoff and send a minimal content-safe prompt referencing plan_id plus task_id plus base_commit plus owned paths plus brief path; Sheepdog reads the authoritative plan via herdr_plan_read before acknowledging its contract. + Topology hardening: prompt only the grazer and sheepdog workers you spawned. Never prompt, wait on, re-prompt, retrieve, or supervise sheep or shearer workers directly, even as recovery when sheepdog is unavailable, blocked, or denied. Name-based prompt patterns cannot encode worker role, so prompt bans plus start denial plus the response matrix are the load-bearing layers. Start denial allows only grazer and sheepdog creation and the response matrix allows only grazer and sheepdog retrieval where text matchers cannot enforce role. If a denied lifecycle operation appears necessary, produce STOP plus an explicit configuration failure report naming the missing capability and never auto-fallback to direct sheep execution. Sheepdog remains the sole supervisor of leaves and the sole path for bounded recovery contracts. Parallelize only through sheepdog squads that will not conflict; require dedicated branches and worktrees with non-overlapping ownership and an explicit integration order in every contract. Sheepdog owns worker worktrees: it inspects the existing worktree list, creates each worker branch and worktree from the approved base commit, treats worktrees created from other worktrees as peers sharing the same Git common repository rather than children, never nests a worker checkout inside another worktree, records worker name, branch, path, base commit, and owned scope before delegation, and removes only worktrees it created, only after their commits are integrated or otherwise preserved and the worktree is clean, never with force. @@ -146,7 +181,7 @@ FINALIZE - all milestones are complete; the final report follows. FINALIZE closes a task and is never an acknowledgement. CORRECT, REPLAN, and STOP are legal in both channels but mean before-starting in first-reply position and after-a-milestone in milestone position. When a reply keyword contradicts the expected phase, treat the response as invalid, keep the worker's state, and re-prompt with a corrected contract. -After grazer or sheepdog settles, use herdr_agent_response as the authoritative result channel. Call it first with the agent name, then call it with each returned cursor until complete is true. Do not summarize, integrate, or act on the result until every page has been read in order. Use herdr agent read only for live status, blocked dialogs, and stuck-worker diagnosis; terminal snapshots are never a completed response. Wait with a bounded poll loop on a short interval: poll herdr agent get about every 10 seconds until settled or the safety timeout expires. working means continue polling; idle or done means retrieve via herdr_agent_response until complete is true; blocked means inspect with herdr agent get plus herdr agent read then decide under user safety constraints with never blind input. Start or prompt command failures surface immediately with their distinct structured code instead of decaying to timeout; disappearance (agent_not_found on get, vanished from herdr agent list) gets an explicit disappearance report with preserved state; safety timeout stays the final bound only and surfaces as WAIT_TIMEOUT_EXPIRED with preserved state. Retries stay bounded. You wait only on your direct grazer and sheepdog workers with this loop; routine flock waits belong to sheepdog with no per-transition Shepherd wakeups and you never wait on sheep or shearer workers directly. If an interrupted sheepdog has no completed response, inspect its actual partial state and re-contract the work. Retrying and re-contracting leaves belongs to sheepdog. Treat unknown as inconclusive, not complete. +After grazer or sheepdog settles, use herdr_agent_response as the authoritative result channel. Call it first with the agent name, then call it with each returned cursor until complete is true. Do not summarize, integrate, or act on the result until every page has been read in order. Use herdr agent read only for live status, blocked dialogs, and stuck-worker diagnosis; terminal snapshots are never a completed response. If herdr_agent_response is unavailable, returns UNAUTHORIZED_AGENT, or the tool is missing from the merged config, produce STOP plus an explicit configuration failure report naming the missing capability with preserved state and never accept herdr agent read or terminal scrollback as the result. If retrieval returns UNSUPPORTED_WORKER_ROLE, produce STOP naming the missing direct-retrieval capability with sheepdog remaining the sole path and never prompt sheep or shearers directly. Wait with a bounded poll loop on a short interval: poll herdr agent get about every 10 seconds until settled or the safety timeout expires. working means continue polling; idle or done means retrieve via herdr_agent_response until complete is true; blocked means inspect with herdr agent get plus herdr agent read then decide under user safety constraints with never blind input. Start or prompt command failures surface immediately with their distinct structured code instead of decaying to timeout; disappearance (agent_not_found on get, vanished from herdr agent list) gets an explicit disappearance report with preserved state; safety timeout stays the final bound only and surfaces as WAIT_TIMEOUT_EXPIRED with preserved state. Retries stay bounded. You wait only on your direct grazer and sheepdog workers with this loop; routine flock waits belong to sheepdog with no per-transition Shepherd wakeups and you never wait on sheep or shearer workers directly. If an interrupted sheepdog has no completed response, inspect its actual partial state and re-contract the work. Retrying and re-contracting leaves belongs to sheepdog. Treat unknown as inconclusive, not complete. If an agent is blocked, inspect it with herdr agent get and herdr agent read then decide; do not answer approvals or questions without applying the user's safety constraints and never blind input. Synthesize agent findings instead of forwarding raw reports. Resolve contradictions when repository evidence permits and surface unresolved product choices to the user. @@ -160,6 +195,8 @@ Shepherd ownership and semantic synchronization: hand off the validated target l ${PANE_POLICY_SHARED_PARAGRAPH} +${ROLE_TAB_POLICY_PARAGRAPH} + ${GOVERNOR_PANE_OWNERSHIP_PARAGRAPH} ${GOVERNOR_PROJECT_PERMISSION_SKILL_PARAGRAPH} @@ -213,6 +250,8 @@ Raw Developer steering is never yours to read directly: the shepherd phases own ${PANE_POLICY_SHARED_PARAGRAPH} +${ROLE_TAB_POLICY_PARAGRAPH} + ${SHEEPDOG_PANE_OWNERSHIP_PARAGRAPH} `.trim(); @@ -265,7 +304,8 @@ Raw Developer steering is not yours: shepherd phases own raw check, read, consum // need no broader spawn authority and no missing CLI primitives. They mirror // the shared normative wording above: four-pane cap per tab, Dev exclusion // in any tab, reuse first within cap, new-tab overflow with indexed role -// labels, startup destinations per tab, and pre-create default minimal. +// labels, startup destinations per tab, role tabs titled at creation with +// the caller tab sacred, plus per-role caps with quadrant geometry. // Caller context stays via current pane ID and never relies on another // client focused pane. export function isDevPane(pane) { @@ -372,3 +412,136 @@ export function sheepdogStartupDestination({ reason: placement.reason, }; } + +export function shepherdStartupDestination({ + panes, + tabId, + existingLabels, + reuseCandidateId, + currentPaneId, +} = {}) { + const label = nextRoleLabel(existingLabels, "grazer"); + const placement = decidePanePlacement({ panes, tabId, reuseCandidateId, currentPaneId }); + return { + label, + action: placement.action, + paneId: placement.paneId, + reason: placement.reason, + }; +} + +export function governorStartupDestination({ + panes, + tabId, + roleCategory, + existingLabels, + reuseCandidateId, + currentPaneId, +} = {}) { + const category = typeof roleCategory === "string" && roleCategory.length > 0 ? roleCategory : "sheepdog"; + const label = category === "grazer" ? nextRoleLabel(existingLabels, "grazer") : nextRoleLabel(existingLabels, "Sheepdog"); + const placement = decidePanePlacement({ panes, tabId, reuseCandidateId, currentPaneId }); + return { + label, + action: placement.action, + paneId: placement.paneId, + reason: placement.reason, + }; +} + +// Role-tab placement helpers (pure, evidence-only, same policy). +// Role tabs are titled at creation and never renamed; the shepherd caller +// tab never hosts worker panes; sheepdog stays alone; grazers and sheep +// fill quadrant tabs up to four panes; shearers fill tabs up to two panes. +// Tabs overflow to indexed role tabs (grazers-2, sheep-2, shearers-2) when +// the per-role cap binds. Roles never mix within a role tab. +export function roleTabCapFor(roleCategory) { + if (roleCategory === "sheepdog") return ROLE_TAB_CAPS.sheepdog; + if (roleCategory === "grazer") return ROLE_TAB_CAPS.grazer; + if (roleCategory === "sheep") return ROLE_TAB_CAPS.sheep; + if (roleCategory === "shearer-low" || roleCategory === "shearer-medium") return ROLE_TAB_CAPS["shearer-low"]; + return PANE_CAP; +} + +export function roleTabBaseLabel(roleCategory) { + if (roleCategory === "sheepdog") return ROLE_TAB_BASE_LABELS.sheepdog; + if (roleCategory === "grazer") return ROLE_TAB_BASE_LABELS.grazer; + if (roleCategory === "sheep") return ROLE_TAB_BASE_LABELS.sheep; + if (roleCategory === "shearer-low" || roleCategory === "shearer-medium") return ROLE_TAB_BASE_LABELS["shearer-low"]; + return "flock"; +} + +export function nextRoleTabLabel(existingTabLabels, roleCategory) { + const base = roleTabBaseLabel(roleCategory); + const labels = Array.isArray(existingTabLabels) ? existingTabLabels : []; + if (!labels.includes(base)) return base; + let index = 2; + while (labels.includes(`${base}-${index}`)) index += 1; + return `${base}-${index}`; +} + +export function roleTabGeometry(roleCategory) { + if (roleCategory === "shearer-low" || roleCategory === "shearer-medium") { + return { panes: 2, steps: ["split right once"] }; + } + if (roleCategory === "sheepdog") { + return { panes: 1, steps: [] }; + } + return { panes: 4, steps: ["split right once", "split each side down once parsing each new pane ID from JSON"] }; +} + +export function sheepdogRoleTabDestination({ + roleCategory, + tabs, + panes, + reuseCandidateId, + callerTabId, +} = {}) { + const category = typeof roleCategory === "string" && roleCategory.length > 0 ? roleCategory : "sheep"; + const cap = Math.min(roleTabCapFor(category), PANE_CAP); + const tabList = Array.isArray(tabs) ? tabs : []; + const paneList = Array.isArray(panes) ? panes : []; + const byId = new Map(paneList.map((pane) => [pane.pane_id, pane])); + const candidate = reuseCandidateId === undefined ? undefined : byId.get(reuseCandidateId); + const candidateTab = candidate ? tabList.find((tab) => tab.tab_id === candidate.tab_id) : undefined; + const candidateLabel = candidateTab ? candidateTab.label : undefined; + const base = roleTabBaseLabel(category); + const candidateInRoleTab = + candidate !== undefined && + !isDevPane(candidate) && + typeof candidateLabel === "string" && + (candidateLabel === base || candidateLabel.startsWith(`${base}-`)) && + candidate.tab_id !== callerTabId; + const managedInRoleTab = (tabId) => managedPanesInTab(paneList, tabId).length; + const roomyRoleTab = tabList.find((tab) => { + if (tab.tab_id === callerTabId) return false; + if (!(tab.label === base || (typeof tab.label === "string" && tab.label.startsWith(`${base}-`)))) return false; + return managedInRoleTab(tab.tab_id) < cap; + }); + if (candidateInRoleTab && managedInRoleTab(candidate.tab_id) <= cap) { + return { + tabLabel: candidateLabel, + action: managedInRoleTab(candidate.tab_id) >= cap ? "overflow-reuse" : "reuse", + paneId: reuseCandidateId, + reason: + managedInRoleTab(candidate.tab_id) >= cap + ? "Reuse first within the per-role cap" + : "Reuse the matching pane when found in its role tab.", + }; + } + if (roomyRoleTab) { + const count = managedInRoleTab(roomyRoleTab.tab_id); + return { + tabLabel: roomyRoleTab.label, + action: count === 0 ? "split" : "split", + paneId: null, + reason: "split only when no reusable same-role pane exists and the per-role cap permits.", + }; + } + return { + tabLabel: nextRoleTabLabel(tabList.map((tab) => tab.label), category), + action: "new-tab", + paneId: null, + reason: "Overflow to a new indexed role tab when the per-role cap binds.", + }; +} diff --git a/test/agents.test.js b/test/agents.test.js index f57160f..6de0d7d 100644 --- a/test/agents.test.js +++ b/test/agents.test.js @@ -788,11 +788,10 @@ test("14-18-M1 pane layout matrices per ownership role with leaves unchanged", ( } assert.equal(shepherdBash["herdr pane close*"], undefined, "shepherd must not close (single pane, no flock cleanup)"); - for (const key of ["herdr tab list*", "herdr pane get*", "herdr pane rename*", "herdr agent rename*"]) { - assert.equal(governorBash[key], "allow", `shepherd-governor must allow ${key} for single Sheepdog pane`); + for (const key of ["herdr tab list*", "herdr tab create*", "herdr pane get*", "herdr pane rename*", "herdr agent rename*"]) { + assert.equal(governorBash[key], "allow", `shepherd-governor must allow ${key} for Sheepdog pane with per-tab overflow`); } - assert.equal(governorBash["herdr tab create*"], undefined, "governor keeps no tab create"); - assert.equal(governorBash["herdr pane close*"], undefined, "governor must not close (single pane, no flock cleanup)"); + assert.equal(governorBash["herdr pane close*"], undefined, "governor must not close (sheepdog owns flock cleanup)"); for (const key of ["herdr tab list*", "herdr tab create*", "herdr pane get*", "herdr pane rename*", "herdr agent rename*", "herdr pane close*"]) { assert.equal(sheepdogBash[key], "allow", `sheepdog must allow ${key} for flock panes per tab with new-tab overflow`); @@ -832,7 +831,7 @@ test("14-18-M1 pane layout evaluation stays effective with separators global las assert.equal(m1EvaluateBash(bash, "herdr agent rename issue1418m1sheep sheep-1"), "allow", `${name} agent rename evaluates allow`); assert.equal(m1EvaluateBash(bash, "herdr tab list --workspace w1K; rm"), "deny", `${name} separator smuggling stays denied`); } - for (const [name, bash] of [["shepherd", shepherdBash], ["sheepdog", sheepdogBash]]) { + for (const [name, bash] of [["shepherd", shepherdBash], ["shepherd-governor", governorBash], ["sheepdog", sheepdogBash]]) { const keys = Object.keys(bash); const tabCreate = keys.indexOf("herdr tab create*"); const sep = keys.indexOf("*;*"); @@ -841,7 +840,6 @@ test("14-18-M1 pane layout evaluation stays effective with separators global las assert.equal(m1EvaluateBash(bash, "herdr tab create --workspace w1K"), "allow", `${name} tab create evaluates allow for per-tab overflow`); assert.equal(m1EvaluateBash(bash, "herdr tab create --workspace w1K; rm"), "deny", `${name} tab create separator smuggling stays denied`); } - assert.equal(m1EvaluateBash(governorBash, "herdr tab create --workspace w1K"), "deny", "governor tab create fails closed to deny"); assert.equal(m1EvaluateBash(sheepdogBash, "herdr pane close w1K:p1"), "allow", "sheepdog pane close evaluates allow for owned flock pane"); assert.equal(m1EvaluateBash(shepherdBash, "herdr pane close w1K:p1"), "deny", "shepherd pane close fails closed to deny"); assert.equal(m1EvaluateBash(governorBash, "herdr pane close w1K:p1"), "deny", "governor pane close fails closed to deny"); @@ -849,7 +847,7 @@ test("14-18-M1 pane layout evaluation stays effective with separators global las test("14-18-M1 pane layout allows tab create for overflow with other tab ops still denied", () => { const agents = createAgents(); - for (const name of ["shepherd", "sheepdog"]) { + for (const name of ["shepherd", "shepherd-governor", "sheepdog"]) { const bash = agents[name].permission.bash; assert.equal(bash["herdr tab create*"], "allow", `${name} must allow tab create for per-tab overflow`); assert.equal(m1EvaluateBash(bash, "herdr tab create w1K"), "allow", `${name} tab create evaluates allow`); @@ -879,7 +877,6 @@ test("14-18-M1 pane layout allows tab create for overflow with other tab ops sti } const governorBash = agents["shepherd-governor"].permission.bash; for (const invented of [ - "herdr tab create*", "herdr tab close*", "herdr tab get*", "herdr tab focus*", @@ -898,6 +895,7 @@ test("14-18-M1 pane layout allows tab create for overflow with other tab ops sti assert.equal(governorBash[invented], undefined, `shepherd-governor must not invent ${invented}`); assert.equal(m1EvaluateBash(governorBash, invented.replace("*", " w1K")), "deny", `${invented} stays denied for shepherd-governor`); } + assert.equal(governorBash["herdr tab create*"], "allow", "governor allows tab create for per-tab overflow"); assert.equal(governorBash["herdr pane split*"], "allow", "governor keeps evidenced split for placement"); assert.equal(governorBash["herdr pane list*"], "allow", "governor keeps evidenced list for scan"); assert.equal(governorBash["herdr pane layout*"], "allow", "governor keeps evidenced layout for geometry"); diff --git a/test/m2-placement-boundary.test.js b/test/m2-placement-boundary.test.js index 01a9906..273d467 100644 --- a/test/m2-placement-boundary.test.js +++ b/test/m2-placement-boundary.test.js @@ -3,16 +3,25 @@ import assert from "node:assert/strict"; import { PANE_CAP, + ROLE_TAB_POLICY_PARAGRAPH, + ROLE_TAB_POLICY_SENTENCES, SHEEPDOG_PROMPT, SHEPHERD_GOVERNOR_PROMPT, SHEPHERD_PROMPT, decidePanePlacement, + governorStartupDestination, isDevPane, managedPanes, managedPanesInTab, nextRoleLabel, + nextRoleTabLabel, preCreateDefaultPane, + roleTabBaseLabel, + roleTabCapFor, + roleTabGeometry, + sheepdogRoleTabDestination, sheepdogStartupDestination, + shepherdStartupDestination, } from "../src/prompts.js"; function pane({ @@ -181,10 +190,10 @@ test("14-18-M2 initial plus dynamic plus focused plus empty tab cases keep Dev e test("14-18-M2 Sheepdog startup named destinations for grazer plus sheep plus shearer categories within cap", () => { assert.match( SHEEPDOG_PROMPT, - /startup destinations for grazer plus sheep plus shearer-low plus shearer-medium worker categories stay within the four-pane cap per tab/, + /startup destinations for grazer plus sheep plus shearer-low plus shearer-medium worker categories stay within the per-role cap/, ); - assert.match(SHEEPDOG_PROMPT, /pre-create default minimal/); - assert.match(SHEEPDOG_PROMPT, /starts in its own Sheepdog pane and starts flock workers in sibling flock panes of the current tab with overflow to a new tab/); + assert.match(SHEEPDOG_PROMPT, /role tabs created lazily on first need/); + assert.match(SHEEPDOG_PROMPT, /stays alone in its own tab titled Sheepdog plus descriptor with no flock workers/); assert.equal(nextRoleLabel([], "sheep"), "sheep-1"); assert.equal(nextRoleLabel(["sheep-1", "sheep-2"], "sheep"), "sheep-3"); @@ -257,6 +266,155 @@ test("14-18-M2 six-step dynamic placement uses the same policy with no separate assert.match(prompt, /Never touch the Dev pane in any tab/); } assert.match(SHEEPDOG_PROMPT, /six-step placement is reuse-first plus evidence-only with new-tab overflow with cap check plus reuse check plus split plus rename plus tab create plus start/); - assert.match(SHEEPDOG_PROMPT, /on cap go to a new tab with indexed role labels and never split a fifth pane/); + assert.match(SHEEPDOG_PROMPT, /on cap go to a new indexed role tab and never split beyond the per-role cap/); assert.match(SHEEPDOG_PROMPT, /reuse capacity-available managed panes first within the cap/); }); + +test("30-M1 shepherd plus governor startup destinations mirror sheepdog placement with Dev excluded", () => { + const room = [pane({ pane_id: "w1K:p1", label: "caller", tab_id: "w1K:t1" })]; + const shepherdDest = shepherdStartupDestination({ panes: room, tabId: "w1K:t1", existingLabels: ["caller"] }); + assert.ok(shepherdDest.label.startsWith("grazer-"), "shepherd starts grazers with indexed labels"); + assert.equal(shepherdDest.action, "split", "room means split"); + + const governorSheepdog = governorStartupDestination({ + panes: room, + tabId: "w1K:t1", + roleCategory: "sheepdog", + existingLabels: ["caller"], + }); + assert.ok(governorSheepdog.label.startsWith("Sheepdog-"), "governor sheepdog uses indexed Sheepdog labels"); + assert.equal(governorSheepdog.action, "split", "room means split"); + + const governorGrazer = governorStartupDestination({ + panes: room, + tabId: "w1K:t1", + roleCategory: "grazer", + existingLabels: ["caller"], + }); + assert.ok(governorGrazer.label.startsWith("grazer-"), "governor grazer uses indexed grazer labels"); + + const full = [ + pane({ pane_id: "w1K:p1", label: "caller" }), + pane({ pane_id: "w1K:p2", label: "sheep-1" }), + pane({ pane_id: "w1K:p3", label: "sheep-2" }), + pane({ pane_id: "w1K:p4", label: "grazer-1" }), + ]; + assert.equal(shepherdStartupDestination({ panes: full, tabId: "w1K:t1", existingLabels: [] }).action, "new-tab"); + assert.equal( + governorStartupDestination({ panes: full, tabId: "w1K:t1", roleCategory: "sheepdog", existingLabels: [] }).action, + "new-tab", + ); + + const withDev = [...room, devPane({ pane_id: "w1K:pDev" })]; + const devExcluded = governorStartupDestination({ + panes: withDev, + tabId: "w1K:t1", + roleCategory: "sheepdog", + existingLabels: ["caller"], + reuseCandidateId: "w1K:pDev", + }); + assert.notEqual(devExcluded.paneId, "w1K:pDev", "Dev never reused for startup"); +}); + +test("32-M1 dedicated role tabs keep the caller tab sacred with quadrant geometry and per-role overflow", () => { + for (const sentence of ROLE_TAB_POLICY_SENTENCES) { + assert.equal(typeof sentence, "string"); + for (const [name, prompt] of [ + ["shepherd", SHEPHERD_PROMPT], + ["shepherd-governor", SHEPHERD_GOVERNOR_PROMPT], + ["sheepdog", SHEEPDOG_PROMPT], + ]) { + assert.ok(prompt.includes(sentence), `${name} must contain role-tab sentence: ${sentence}`); + } + } + for (const [name, prompt] of [ + ["shepherd", SHEPHERD_PROMPT], + ["shepherd-governor", SHEPHERD_GOVERNOR_PROMPT], + ["sheepdog", SHEEPDOG_PROMPT], + ]) { + assert.ok(prompt.includes(ROLE_TAB_POLICY_PARAGRAPH), `${name} must contain the role-tab paragraph verbatim`); + } + + assert.equal(roleTabCapFor("sheepdog"), 1); + assert.equal(roleTabCapFor("grazer"), 4); + assert.equal(roleTabCapFor("sheep"), 4); + assert.equal(roleTabCapFor("shearer-low"), 2); + assert.equal(roleTabCapFor("shearer-medium"), 2); + assert.equal(roleTabBaseLabel("sheepdog"), "Sheepdog"); + assert.equal(roleTabBaseLabel("grazer"), "grazers"); + assert.equal(roleTabBaseLabel("sheep"), "sheep"); + assert.equal(roleTabBaseLabel("shearer-low"), "shearers"); + assert.equal(nextRoleTabLabel([], "grazer"), "grazers"); + assert.equal(nextRoleTabLabel(["grazers"], "grazer"), "grazers-2"); + assert.equal(nextRoleTabLabel(["grazers", "grazers-2"], "grazer"), "grazers-3"); + assert.deepEqual(roleTabGeometry("sheepdog"), { panes: 1, steps: [] }); + assert.equal(roleTabGeometry("grazer").panes, 4); + assert.equal(roleTabGeometry("sheep").panes, 4); + assert.deepEqual(roleTabGeometry("shearer-low"), { panes: 2, steps: ["split right once"] }); + + const tabs = [ + { tab_id: "w1K:t0", label: "1" }, + { tab_id: "w1K:t1", label: "Sheepdog" }, + { tab_id: "w1K:t2", label: "grazers" }, + ]; + const panes = [ + pane({ pane_id: "w1K:p0", tab_id: "w1K:t0", label: "caller" }), + pane({ pane_id: "w1K:p9", tab_id: "w1K:t1", label: "Sheepdog" }), + pane({ pane_id: "w1K:p1", tab_id: "w1K:t2", label: "grazer-1" }), + ]; + const roomy = sheepdogRoleTabDestination({ roleCategory: "grazer", tabs, panes, callerTabId: "w1K:t0" }); + assert.equal(roomy.tabLabel, "grazers"); + assert.equal(roomy.action, "split"); + assert.notEqual(roomy.tabLabel, "1", "never places on the caller tab"); + + const reuse = sheepdogRoleTabDestination({ + roleCategory: "grazer", + tabs, + panes, + reuseCandidateId: "w1K:p1", + callerTabId: "w1K:t0", + }); + assert.equal(reuse.action, "reuse"); + assert.equal(reuse.paneId, "w1K:p1"); + + const callerCandidate = sheepdogRoleTabDestination({ + roleCategory: "grazer", + tabs, + panes, + reuseCandidateId: "w1K:p0", + callerTabId: "w1K:t0", + }); + assert.notEqual(callerCandidate.tabLabel, "1", "a caller-tab candidate never satisfies role reuse"); + + const sheepDest = sheepdogRoleTabDestination({ roleCategory: "sheep", tabs, panes, callerTabId: "w1K:t0" }); + assert.equal(sheepDest.action, "new-tab"); + assert.equal(sheepDest.tabLabel, "sheep"); + + const fullPanes = [ + ...panes, + pane({ pane_id: "w1K:p2", tab_id: "w1K:t2", label: "grazer-2" }), + pane({ pane_id: "w1K:p3", tab_id: "w1K:t2", label: "grazer-3" }), + pane({ pane_id: "w1K:p4", tab_id: "w1K:t2", label: "grazer-4" }), + ]; + const overflow = sheepdogRoleTabDestination({ + roleCategory: "grazer", + tabs, + panes: fullPanes, + callerTabId: "w1K:t0", + }); + assert.equal(overflow.action, "new-tab"); + assert.equal(overflow.tabLabel, "grazers-2"); + + const devInRoleTab = [ + ...panes, + devPane({ pane_id: "w1K:pDev", tab_id: "w1K:t2" }), + ]; + const devReuse = sheepdogRoleTabDestination({ + roleCategory: "grazer", + tabs, + panes: devInRoleTab, + reuseCandidateId: "w1K:pDev", + callerTabId: "w1K:t0", + }); + assert.notEqual(devReuse.paneId, "w1K:pDev", "Dev never reused for role placement"); +}); diff --git a/test/m2-prompt-policy.test.js b/test/m2-prompt-policy.test.js index fba690d..d3d7b5d 100644 --- a/test/m2-prompt-policy.test.js +++ b/test/m2-prompt-policy.test.js @@ -9,6 +9,8 @@ import { PANE_CAP, PANE_POLICY_SHARED_PARAGRAPH, PANE_POLICY_SHARED_SENTENCES, + ROLE_TAB_POLICY_PARAGRAPH, + ROLE_TAB_POLICY_SENTENCES, SHEEP_PROMPT, SHEEPDOG_PANE_OWNERSHIP_PARAGRAPH, SHEEPDOG_PROMPT, @@ -52,17 +54,18 @@ test("14-18-M2 shared paragraph present verbatim in every spawning prompt", () = test("14-18-M2 role-specific ownership plus capacity plus grouping plus startup differs per role", () => { assert.ok(SHEPHERD_PROMPT.includes(SHEPHERD_PANE_OWNERSHIP_PARAGRAPH)); - assert.ok(SHEPHERD_PROMPT.includes("shepherd manages its single Sheepdog pane scan plus placement plus rename plus tab create only")); - assert.ok(SHEPHERD_PROMPT.includes("starts its grazer in a sibling pane of the current tab with overflow to a new tab")); + assert.ok(SHEPHERD_PROMPT.includes("shepherd manages scan plus placement plus rename plus tab create and never closes")); + assert.ok(SHEPHERD_PROMPT.includes("starts its grazers in dedicated grazers role tabs and never places panes on the calling tab")); assert.ok(SHEPHERD_GOVERNOR_PROMPT.includes(GOVERNOR_PANE_OWNERSHIP_PARAGRAPH)); - assert.ok(SHEPHERD_GOVERNOR_PROMPT.includes("shepherd-governor manages its single Sheepdog pane scan plus placement plus rename only")); - assert.ok(SHEPHERD_GOVERNOR_PROMPT.includes("starts its sheepdog in a dedicated sibling Sheepdog pane of the current tab")); + assert.ok(SHEPHERD_GOVERNOR_PROMPT.includes("shepherd-governor manages scan plus placement plus rename plus tab create and never closes flock panes")); + assert.ok(SHEPHERD_GOVERNOR_PROMPT.includes("starts its sheepdog alone in its own tab titled Sheepdog plus descriptor")); assert.ok(SHEEPDOG_PROMPT.includes(SHEEPDOG_PANE_OWNERSHIP_PARAGRAPH)); - assert.ok(SHEEPDOG_PROMPT.includes("sheepdog manages flock panes scan plus placement plus rename plus close plus tab create up to the per-tab cap")); + assert.ok(SHEEPDOG_PROMPT.includes("sheepdog manages flock panes scan plus placement plus rename plus close plus tab create across dedicated role tabs")); assert.ok(SHEEPDOG_PROMPT.includes("only the creator may rename plus close its panes")); - assert.ok(SHEEPDOG_PROMPT.includes("startup destinations for grazer plus sheep plus shearer-low plus shearer-medium worker categories stay within the four-pane cap per tab")); + assert.ok(SHEEPDOG_PROMPT.includes("stays alone in its own tab titled Sheepdog plus descriptor with no flock workers")); + assert.ok(SHEEPDOG_PROMPT.includes("startup destinations for grazer plus sheep plus shearer-low plus shearer-medium worker categories stay within the per-role cap")); assert.ok(SHEEPDOG_PROMPT.includes("six-step placement is reuse-first plus evidence-only with new-tab overflow")); assert.ok(!SHEPHERD_PROMPT.includes(GOVERNOR_PANE_OWNERSHIP_PARAGRAPH)); @@ -80,10 +83,14 @@ test("14-18-M2 leaves stay unchanged with no pane policy", () => { ["shearer", SHEARER_REVIEW_PROMPT], ]) { assert.ok(!prompt.includes(PANE_POLICY_SHARED_PARAGRAPH), `${name} must not contain the shared pane paragraph`); + assert.ok(!prompt.includes(ROLE_TAB_POLICY_PARAGRAPH), `${name} must not contain the role-tab paragraph`); for (const sentence of PANE_POLICY_SHARED_SENTENCES) { assert.ok(!prompt.includes(sentence), `${name} must not contain shared sentence: ${sentence}`); } - assert.ok(!prompt.includes("manages its single Sheepdog pane")); + for (const sentence of ROLE_TAB_POLICY_SENTENCES) { + assert.ok(!prompt.includes(sentence), `${name} must not contain role-tab sentence: ${sentence}`); + } + assert.ok(!prompt.includes("manages scan plus placement")); assert.ok(!prompt.includes("manages flock panes")); } }); diff --git a/test/m2-topology-hardening.test.js b/test/m2-topology-hardening.test.js index c462a2d..0ad44b2 100644 --- a/test/m2-topology-hardening.test.js +++ b/test/m2-topology-hardening.test.js @@ -317,3 +317,37 @@ test("21-M2 governor legitimate grazer plus sheepdog spawn plus retrieval plus p assert.match(SHEPHERD_GOVERNOR_PROMPT, /herdr_plan_read/); assert.match(SHEPHERD_GOVERNOR_PROMPT, /Sheepdog owns worker worktrees/); }); + +test("31-M1 governor delegation is content-safe by construction with file-based large contracts", () => { + assert.match(SHEPHERD_GOVERNOR_PROMPT, /content-safe/); + assert.match(SHEPHERD_GOVERNOR_PROMPT, /even inside quotes/); + assert.match(SHEPHERD_GOVERNOR_PROMPT, /fails closed/); + assert.match(SHEPHERD_GOVERNOR_PROMPT, /split or rephrase/); + assert.match(SHEPHERD_GOVERNOR_PROMPT, /Markdown brief or handoff/); + assert.match(SHEPHERD_GOVERNOR_PROMPT, /herdr_plan_read before acknowledging/); + const bash = createAgents()["shepherd-governor"].permission.bash; + assert.equal( + m2EvaluateBash(bash, "herdr agent prompt squad_1 bounded task without separators --wait --timeout 1000"), + "allow", + "clean governor prompt stays allow", + ); + for (const cmd of [ + 'herdr agent prompt squad_1 "fix; do X" --wait --timeout 1000', + 'herdr agent prompt squad_1 "a && b" --wait --timeout 1000', + 'herdr agent prompt squad_1 "a || b" --wait --timeout 1000', + 'herdr agent prompt squad_1 "a | b" --wait --timeout 1000', + 'herdr agent prompt squad_1 "a > b" --wait --timeout 1000', + 'herdr agent prompt squad_1 "a < b" --wait --timeout 1000', + ]) { + assert.equal(m2EvaluateBash(bash, cmd), "deny", `separator task text must fail closed: ${cmd}`); + } +}); + +test("32-M1 governor retrieval fails closed without accepting terminal read", () => { + assert.match(SHEPHERD_GOVERNOR_PROMPT, /terminal snapshots are never a completed response/); + assert.match(SHEPHERD_GOVERNOR_PROMPT, /herdr_agent_response until complete/); + assert.match(SHEPHERD_GOVERNOR_PROMPT, /returns UNAUTHORIZED_AGENT/); + assert.match(SHEPHERD_GOVERNOR_PROMPT, /never accept herdr agent read or terminal scrollback as the result/); + assert.match(SHEPHERD_GOVERNOR_PROMPT, /UNSUPPORTED_WORKER_ROLE/); + assert.match(SHEPHERD_GOVERNOR_PROMPT, /never prompt sheep or shearers directly/); +}); diff --git a/test/plugin.test.js b/test/plugin.test.js index 979b6b6..0d83526 100644 --- a/test/plugin.test.js +++ b/test/plugin.test.js @@ -737,10 +737,9 @@ test("14-18-M1 pane layout survives plugin config with leaves unchanged", async assert.equal(config.agent.shepherd.permission.bash[key], "allow", `plugin shepherd keeps ${key} for per-tab overflow`); } assert.equal(config.agent.shepherd.permission.bash["herdr pane close*"], undefined, "plugin shepherd keeps no close"); - for (const key of ["herdr tab list*", "herdr pane get*", "herdr pane rename*", "herdr agent rename*"]) { - assert.equal(config.agent["shepherd-governor"].permission.bash[key], "allow", `plugin shepherd-governor keeps ${key} for single Sheepdog pane`); + for (const key of ["herdr tab list*", "herdr tab create*", "herdr pane get*", "herdr pane rename*", "herdr agent rename*"]) { + assert.equal(config.agent["shepherd-governor"].permission.bash[key], "allow", `plugin shepherd-governor keeps ${key} for Sheepdog pane with per-tab overflow`); } - assert.equal(config.agent["shepherd-governor"].permission.bash["herdr tab create*"], undefined, "plugin governor keeps no tab create"); assert.equal(config.agent["shepherd-governor"].permission.bash["herdr pane close*"], undefined, "plugin governor keeps no close"); const sheepdogBash = config.agent.sheepdog.permission.bash; for (const key of ["herdr tab list*", "herdr tab create*", "herdr pane get*", "herdr pane rename*", "herdr agent rename*", "herdr pane close*"]) { @@ -803,8 +802,8 @@ test("14-18-M1 pane layout single normative wording with Dev exclusion from sour ]) { assert.ok(PANE_POLICY_SHARED_PARAGRAPH.includes(required), `shared pane paragraph must include ${required}`); } - assert.ok(SHEPHERD_PANE_OWNERSHIP_PARAGRAPH.includes("shepherd manages its single Sheepdog pane")); - assert.ok(GOVERNOR_PANE_OWNERSHIP_PARAGRAPH.includes("shepherd-governor manages its single Sheepdog pane")); + assert.ok(SHEPHERD_PANE_OWNERSHIP_PARAGRAPH.includes("shepherd manages scan plus placement")); + assert.ok(GOVERNOR_PANE_OWNERSHIP_PARAGRAPH.includes("shepherd-governor manages scan plus placement")); assert.ok(SHEEPDOG_PANE_OWNERSHIP_PARAGRAPH.includes("sheepdog manages flock panes")); assert.ok(SHEEPDOG_PANE_OWNERSHIP_PARAGRAPH.includes("startup destinations for grazer plus sheep plus shearer-low plus shearer-medium")); });