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
test(core): validate issue and pull reference authors [C7]
Corey Olson2546800ae020
diff --git a/test/pr-bridge-fixture.js b/test/pr-bridge-fixture.jsindex 1ad95543..f86223e5 100644--- a/test/pr-bridge-fixture.js+++ b/test/pr-bridge-fixture.js@@ -102,7 +102,9 @@ export function landBridgeItems(box, { independent = false, briefs = [] } = {})/** Stand in for GitHub over real HTTP, refusing every merge endpoint. */export async function bridgeProvider(t, box) {- const state = { requests: [], pulls: [], checks: [], statuses: [], annotations: [], annotationsByRun: {}, next: 1 };+ const state = { requests: [], pulls: [], checks: [], statuses: [], annotations: [], annotationsByRun: {}, next: 1,+ references: { pulls: { 7: { number: 7, user: { login: 'pr-author' } } },+ issues: { 6: { number: 6, user: { login: 'issue-author' } } } } };const server = createServer(async (req, res) => {let raw = '';for await (const chunk of req) raw += chunk;@@ -117,7 +119,7 @@ export async function bridgeProvider(t, box) {if (req.method === 'POST') {const head = box.git(box.remote, 'rev-parse', `refs/heads/${body.head}`);const pull = { number: state.next++, html_url: `https://github.com/fixture/repository/pull/${state.next - 1}`,- title: body.title, body: body.body, state: 'open', merged: false,+ title: body.title, body: body.body, state: 'open', merged: false, user: { login: 'pr-author' },head: { ref: body.head, sha: head }, base: { ref: body.base, sha: box.git(box.remote, 'rev-parse', body.base) }, merged_by: null, merge_commit_sha: null };state.pulls.push(pull); return reply(201, pull);}@@ -136,10 +138,18 @@ export async function bridgeProvider(t, box) {const files = box.git(box.remote, 'diff', '--name-only', `${pull.base.sha}...${pull.head.sha}`).split('\n').filter(Boolean);return reply(200, files.map(filename => ({ filename })));}+ const issueRoute = /^\/repos\/fixture\/repository\/issues\/(\d+)$/u.exec(url.pathname);+ if (issueRoute && req.method === 'GET') {+ const issue = state.references.issues[issueRoute[1]];+ return issue ? reply(200, issue) : reply(404, { message: 'missing private issue' });+ }const pullRoute = /^\/repos\/fixture\/repository\/pulls\/(\d+)$/u.exec(url.pathname);if (pullRoute) {const pull = state.pulls.find(p => p.number === Number(pullRoute[1]));- if (!pull) return reply(404, { message: 'missing private pull' });+ if (!pull) {+ const reference = state.references.pulls[pullRoute[1]];+ return reference ? reply(200, reference) : reply(404, { message: 'missing private pull' });+ }if (req.method === 'PATCH') {Object.assign(pull, { title: body.title, body: body.body });pull.head.sha = box.git(box.remote, 'rev-parse', `refs/heads/${pull.head.ref}`);diff --git a/test/references.test.js b/test/references.test.jsindex 34073cd9..58a7372c 100644--- a/test/references.test.js+++ b/test/references.test.js@@ -193,3 +193,49 @@ test('reference point 20: Submit reminds without refusing and only for missing n'private unhandled references do not acquire an acknowledgement check');});});+++test('GitHub issue and pull references check explicit author handles during async add and edit [C7]', async t => {+ const box = bridgeProject(t);+ const provider = await bridgeProvider(t, box);+ const referenceCalls = path => provider.requests.filter(request => request.method === 'GET' && request.path === path).length;+ const issuePath = '/repos/fixture/repository/issues/6';+ const pullPath = '/repos/fixture/repository/pulls/7';++ const wrongIssue = await runBridgeCLI(box, 'add', 'web', 'Wrong issue author', '--brief',+ 'Reference: https://github.com/fixture/repository/issues/6 @another-person', '--json');+ assert.notEqual(wrongIssue.code, 0, 'an explicit handle that differs from the issue author is refused');+ assert.match(`${wrongIssue.out}\n${wrongIssue.err}`, /issue-author/iu);+ assert.equal(referenceCalls(issuePath), 1, 'issue author is checked through the private provider');++ const matchingIssue = await runBridgeCLI(box, 'add', 'web', 'Matching issue author', '--brief',+ 'Reference: https://github.com/fixture/repository/issues/6 @ISSUE-AUTHOR', '--json');+ assert.equal(matchingIssue.code, 0, matchingIssue.err || matchingIssue.out);+ assert.equal(referenceCalls(issuePath), 2, 'GitHub login matching is case-insensitive');++ const beforeUnhandled = referenceCalls(issuePath) + referenceCalls(pullPath);+ const unhandledAdd = await runBridgeCLI(box, 'add', 'web', 'Unhandled reference', '--brief',+ 'Reference: https://github.com/fixture/repository/issues/6', '--json');+ assert.equal(unhandledAdd.code, 0, unhandledAdd.err || unhandledAdd.out);+ const itemId = JSON.parse(unhandledAdd.out).item.item_id;+ assert.equal(referenceCalls(issuePath) + referenceCalls(pullPath), beforeUnhandled,+ 'an issue reference without an explicit handle performs no author lookup');++ const wrongPull = await runBridgeCLI(box, 'edit', String(itemId), '--brief',+ 'Reference: https://github.com/fixture/repository/pull/7 @another-person', '--json');+ assert.notEqual(wrongPull.code, 0, 'an explicit handle that differs from the pull author is refused');+ assert.match(`${wrongPull.out}\n${wrongPull.err}`, /pr-author/iu);+ assert.equal(referenceCalls(pullPath), 1, 'pull author is checked through the private provider');++ const matchingPull = await runBridgeCLI(box, 'edit', String(itemId), '--brief',+ 'Reference: https://github.com/fixture/repository/pull/7 @PR-AUTHOR', '--json');+ assert.equal(matchingPull.code, 0, matchingPull.err || matchingPull.out);+ assert.equal(referenceCalls(pullPath), 2, 'pull login matching is case-insensitive too');++ const beforeUnhandledEdit = referenceCalls(issuePath) + referenceCalls(pullPath);+ const unhandledEdit = await runBridgeCLI(box, 'edit', String(itemId), '--brief',+ 'Reference: https://github.com/fixture/repository/pull/7', '--json');+ assert.equal(unhandledEdit.code, 0, unhandledEdit.err || unhandledEdit.out);+ assert.equal(referenceCalls(issuePath) + referenceCalls(pullPath), beforeUnhandledEdit,+ 'an edit without an explicit handle performs no author lookup');+});