Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
fix(core): a repo name shared inside a project is never guessed [N34]
Corey Olsonc4663ffcbbca
diff --git a/src/commands/answer.js b/src/commands/answer.jsindex a8902341..6e4a31b1 100644--- a/src/commands/answer.js+++ b/src/commands/answer.js@@ -3,7 +3,7 @@ import { basename } from 'node:path';import * as store from '../board.js';import {projectSiblings,- resolveSibling,+ resolveRepo,} from '../project-decisions.js';import {parseImplies,@@ -29,10 +29,10 @@ export async function run(io, { first, second, rest, values }) {if (reference) {// repo#id names a decision on another repo of this project; the answer runs on that repo's own board [N34].const ctx = context(io);- const here = ctx.config.name ?? basename(ctx.info.root);- if (reference[1] !== here) {- const sibling = resolveSibling(reference[1], projectSiblings(ctx.info.root, ctx.config));- const there = Object.create(io, { cwd: { value: sibling.root } });+ const self = { root: ctx.info.root, name: ctx.config.name ?? basename(ctx.info.root) };+ const target = resolveRepo(reference[1], self, projectSiblings(ctx.info.root, ctx.config));+ if (target.root !== self.root) {+ const there = Object.create(io, { cwd: { value: target.root } });return run(there, { first: reference[2], second, rest, values });}return run(io, { first: reference[2], second, rest, values });diff --git a/src/commands/decisions.js b/src/commands/decisions.jsindex e9c397e1..bb95ae7e 100644--- a/src/commands/decisions.js+++ b/src/commands/decisions.js@@ -4,6 +4,7 @@ import * as store from '../board.js';import {projectPersonDecisions,projectSiblings,+ repoLabels,} from '../project-decisions.js';import {agentDisplayName,@@ -22,12 +23,15 @@ import {*/export function run(io, { values }) {const ctx = context(io);- const siblings = projectSiblings(ctx.info.root, ctx.config);+ const self = { root: ctx.info.root, name: ctx.config.name ?? basename(ctx.info.root) };+ const found = projectSiblings(ctx.info.root, ctx.config);+ const labels = repoLabels(self, found);+ const siblings = found.map((entry) => ({ ...entry, label: labels.get(entry.root) }));const { asks, agents, project, asPerson } = withBoardRead(ctx, (board) => {const me = whoAmI(ctx, board);const asPerson = personMode(ctx, me, values);if (asPerson && siblings.length) {- return { project: projectPersonDecisions(ctx.info.root, ctx.config.name ?? basename(ctx.info.root), board, siblings), asPerson };+ return { project: projectPersonDecisions(ctx.info.root, labels.get(self.root), board, siblings), asPerson };}return { asks: store.openDecisions(board, asPerson ? 'person' : [me.id, me.lane]), agents: store.listAgents(board), asPerson };});diff --git a/src/project-decisions.js b/src/project-decisions.jsindex cd01a830..fed0c6b1 100644--- a/src/project-decisions.js+++ b/src/project-decisions.js@@ -31,23 +31,43 @@ export function projectSiblings(root, config, projects = listApiProjects) {}/**- * Resolve the repo part of a repo#id reference to a sibling of this project. A name that matches- * more than one sibling, or none, refuses with the next step, because answering the wrong board- * would close somebody else's decision.+ * Name each repo of a project so repo#id is never ambiguous: a repo goes by its configured name,+ * or by its folder name when another repo of the project has the same configured name.*- * @param {string} repo a registered name or folder name+ * @param {{ root: string, name: string }} self this repo* @param {{ root: string, name: string }[]} siblings- * @returns {{ root: string, name: string }}+ * @returns {Map<string, string>} each repo's root to the label that addresses it*/-export function resolveSibling(repo, siblings) {- const found = siblings.filter((entry) => entry.name === repo || basename(entry.root) === repo);+export function repoLabels(self, siblings) {+ const all = [self, ...siblings];+ return new Map(all.map((entry) => [entry.root, all.filter((other) => other.name === entry.name).length > 1 ? basename(entry.root) : entry.name]));+}++/**+ * Resolve the repo part of a repo#id reference among this repo and its siblings. A label that+ * matches none, or more than one, refuses with the next step, because answering the wrong board+ * would close somebody else's decision; this repo takes part in the match, so a sibling that shares+ * its name is never silently skipped.+ *+ * @param {string} repo a label from repoLabels, a configured name or a folder name+ * @param {{ root: string, name: string }} self this repo+ * @param {{ root: string, name: string }[]} siblings+ * @returns {{ root: string, name: string }} the repo to answer on; may be this repo+ */+export function resolveRepo(repo, self, siblings) {+ const all = [self, ...siblings];+ const labels = repoLabels(self, siblings);+ const byLabel = all.filter((entry) => labels.get(entry.root) === repo);+ if (byLabel.length === 1) return byLabel[0];+ const found = byLabel.length ? byLabel : all.filter((entry) => entry.name === repo || basename(entry.root) === repo);if (found.length === 1) return found[0];throw new Refused(found.length ? 'PROJECT_REPO_AMBIGUOUS' : 'PROJECT_REPO_UNKNOWN',`${found.length ? 'more than one' : 'no'} repo of this project is named ${repo}; run pullboard decisions --as person to see each repo's name`);}/**- * Every open person decision of this repo and of each sibling repo, as `{ ask, repo, root, agents, config }` with the repo also on the ask. A+ * Every open person decision of this repo and of each sibling repo, as `{ ask, repo, root, agents, config }` with the repo also on the ask.+ * Siblings may carry the `label` that repoLabels gave them. A* sibling that cannot be read is skipped and named in `unreadable`, so one broken repo never hides* the others' questions.*@@ -69,9 +89,9 @@ export function projectPersonDecisions(root, repo, board, siblings, configFor =const agents = store.listAgents(other);let config = null;try { config = configFor(sibling.root); } catch { /* names fall back to this repo's settings */ }- for (const ask of store.openDecisions(other, store.PERSON)) decisions.push({ ask: { ...ask, repo: sibling.name }, repo: sibling.name, root: sibling.root, agents, config });+ for (const ask of store.openDecisions(other, store.PERSON)) decisions.push({ ask: { ...ask, repo: sibling.label ?? sibling.name }, repo: sibling.label ?? sibling.name, root: sibling.root, agents, config });} catch {- unreadable.push(sibling.name);+ unreadable.push(sibling.label ?? sibling.name);} finally {try { other?.db.close(); } catch { /* the read is already done */ }}diff --git a/test/team.test.js b/test/team.test.jsindex 4129699e..cfb44fd0 100644--- a/test/team.test.js+++ b/test/team.test.js@@ -938,3 +938,22 @@ test("one decision list across a project's repos [N34]", { timeout: 180_000 }, aassert.notEqual(unknown.code, 0);assert.match(unknown.err, /PROJECT_REPO_UNKNOWN/);});++test('two repos of a project that share a name are addressed by folder, never guessed [N34]', { timeout: 120_000 }, () => { // budget: hang ceiling for two real repos' CLI runs; not a speed target.+ const box = helpers.project();+ const other = siblingRepo(box, 'repo-twin').repo;+ nameRepo(box, box.repo, 'twin', 'shop');+ nameRepo(box, other, 'twin', 'shop');+ const ask = (root, text) => Number(/as #(\d+)/.exec(box.run(root, 'shout', 'person', text, '--decision').out)?.[1]);+ ask(box.repo, 'Ship first?');+ const secondId = ask(other, 'Ship second?');+ const listed = JSON.parse(box.run(box.repo, 'decisions', '--as', 'person', '--json').out).decisions.map(({ repo }) => repo).sort();+ assert.deepEqual(listed, ['repo', 'repo-twin']);+ const guessed = box.run(box.repo, 'answer', `twin#${secondId}`, 'yes', '--as', 'person');+ assert.notEqual(guessed.code, 0);+ assert.match(guessed.err, /PROJECT_REPO_AMBIGUOUS/);+ assert.equal(withBoard(other, board => store.openDecisions(board, store.PERSON)).length, 1, 'nothing closed on either board');+ assert.equal(box.run(box.repo, 'answer', `repo-twin#${secondId}`, 'yes', '--as', 'person').code, 0);+ assert.deepEqual(withBoard(other, board => store.openDecisions(board, store.PERSON)), []);+ assert.equal(withBoard(box.repo, board => store.openDecisions(board, store.PERSON)).length, 1, 'the same-numbered question here stays open');+});