diff --git a/build/cli/index.js b/build/cli/index.js index 4d014f14b..8bc6f5f28 100755 --- a/build/cli/index.js +++ b/build/cli/index.js @@ -147852,7 +147852,7 @@ function intervals(patch) { return Array.from(patch.matchAll(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/gmu), match => { const start = Number(match[1]); return [start, start + Number(match[2] ?? 1) - 1]; - }); + }).filter(([start, end]) => start <= end); } function makeBroker({ repo, officialDirectory, catalog = [], localRuntime, readLocalSqlite, resolvedVersions = [], installedOfficial, readCi, pullRequest }, subject, finding, sharedRead, signal) { diff --git a/build/github_action/index.js b/build/github_action/index.js index 0ee3642c3..e752aa0fc 100644 --- a/build/github_action/index.js +++ b/build/github_action/index.js @@ -241597,7 +241597,7 @@ function intervals(patch) { return Array.from(patch.matchAll(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/gmu), match => { const start = Number(match[1]); return [start, start + Number(match[2] ?? 1) - 1]; - }); + }).filter(([start, end]) => start <= end); } function makeBroker({ repo, officialDirectory, catalog = [], localRuntime, readLocalSqlite, resolvedVersions = [], installedOfficial, readCi, pullRequest }, subject, finding, sharedRead, signal) { diff --git a/docs/bugbot/quality-observability.mdx b/docs/bugbot/quality-observability.mdx index c53b8c141..2361d3b62 100644 --- a/docs/bugbot/quality-observability.mdx +++ b/docs/bugbot/quality-observability.mdx @@ -1049,3 +1049,18 @@ Future qualification plans also pin the actual prepared executable's digest and any launcher artifact. A version string alone cannot admit a model call. Record and check the runtime proof for every corpus invocation; frozen campaigns continue to replay through their own preregistration commits. + +### Deletion-only citation metadata + +A deletion-only hunk contains no new-side changed lines. A citation spanning +adjacent unchanged lines in the head therefore records `inChangedLines=false`. +Nonempty addition/replacement intervals retain their existing overlap behavior. +This metadata describes the cited source; it does not relocate a finding or +replace the immutable LEFT deletion anchor. A legitimate LEFT citation still +uses the pinned comparison base and its original range. Blob/SHA, range, +candidate-bound receipt and prior-delivery validation remain mandatory. + +The [deletion metadata regression](https://github.com/vypdev/copilot/issues/973) +uses six real Git/broker controls and preserves the original negative control. +It changes no evaluator label, score floor, model input authority or historical +campaign. Production verification remains disabled. diff --git a/quality/bugbot/evidence/issue-950/shadow-verification/verification.test.cjs b/quality/bugbot/evidence/issue-950/shadow-verification/verification.test.cjs index 6f2e87e75..0602aed82 100644 --- a/quality/bugbot/evidence/issue-950/shadow-verification/verification.test.cjs +++ b/quality/bugbot/evidence/issue-950/shadow-verification/verification.test.cjs @@ -95,6 +95,55 @@ const cite = (source, first = source.first, last = source.last) => ({ receipt: s const counter = value => ({ input_tokens: value, output_tokens: value, cached_input_tokens: value }); const run = (transport, log = () => {}, signal, input = subject) => investigate(lab, input, finding, null, transport, log, signal); +for (const scenario of [ + { name: 'deletion-only hunk spanning both adjacent unchanged lines', + before: 'one\ntwo\nremoved\nfour\nfive\n', after: 'one\ntwo\nfour\nfive\n', first: 1, last: 2, changed: false, side: 'LEFT' }, + { name: 'multiple deletion-only hunks', before: 'one\ntwo\nremoved-a\nfour\nfive\nremoved-b\nseven\n', + after: 'one\ntwo\nfour\nfive\nseven\n', first: 1, last: 5, changed: false, side: 'LEFT' }, + { name: 'true addition', before: 'one\ntwo\nthree\n', after: 'one\ntwo\nadded\nthree\n', first: 3, last: 3, changed: true }, + { name: 'mixed replacement hunk', before: 'one\ntwo\nremoved-a\nremoved-b\nfive\n', + after: 'one\ntwo\nadded\nfive\n', first: 3, last: 3, changed: true }, + { name: 'unchanged boundary beside deletion and a separate addition', before: 'one\ntwo\nremoved\nfour\nfive\n', + after: 'one\ntwo\nfour\nfive\nadded\n', first: 1, last: 2, changed: false, anchorLine: 5 }, + { name: 'legitimate LEFT deletion citation', before: 'one\ntwo\nremoved\nfour\nfive\n', + after: 'one\ntwo\nfour\nfive\n', first: 3, last: 3, changed: false, revision: 'base', side: 'LEFT' }, +]) { + test('citation change metadata preserves pinned receipts and anchors: ' + scenario.name, async () => { + const commit = (contents, parent) => { + const blob = git(['hash-object', '-w', '--stdin'], contents); + const tree = git(['mktree'], `100644 blob ${blob}\tchange.ts\n`); + const sha = git(['commit-tree', tree, ...(parent ? ['-p', parent] : []), '-m', 'fixed citation fixture']); + return { blob, tree, sha }; + }; + const before = commit(scenario.before), current = commit(scenario.after, before.sha); + const selected = { repository: 'local/fixture', head: current.sha, tree: current.tree, + base: before.sha, baseTree: before.tree }; + const anchor = Object.freeze({ path: 'change.ts', line: scenario.anchorLine ?? 3, + end: scenario.anchorLine ?? 3, side: scenario.side ?? 'RIGHT' }); + const candidate = Object.freeze({ ...finding, detectorLocation: anchor, allowBase: true }); + const broker = makeBroker(lab, selected, candidate); + const revision = scenario.revision ?? 'head'; + const result = await broker.inspect(query('read', 'change.ts', { revision, + first: scenario.first, last: scenario.last })); + assert.equal(result.status, 'provided'); + const citation = cite(result.sources[0]); + const actual = broker.cite(citation); + assert.equal(actual.inChangedLines, scenario.changed); + assert.equal(actual.sha, revision === 'base' ? before.sha : current.sha); + assert.equal(actual.blob, revision === 'base' ? before.blob : current.blob); + assert.deepEqual([actual.first, actual.last], [scenario.first, scenario.last]); + assert.equal(candidate.detectorLocation, anchor); + const foreign = makeBroker(lab, selected, { ...candidate, id: 'foreign-candidate' }); + assert.throws(() => foreign.cite(citation), /citation-unavailable/u); + assert.throws(() => broker.cite({ ...citation, last: scenario.last + 1 }), /range/u); + if (revision === 'base') { + const initial = broker.initialAnchor(); + assert.equal(initial.result.sources[0].sha, before.sha); + assert.deepEqual(candidate.detectorLocation, { path: 'change.ts', line: 3, end: 3, side: 'LEFT' }); + } + }); +} + test('an empty Git blob has no citable first line', async () => { const broker = makeBroker(lab, subject, finding); assert.deepEqual(await broker.inspect(query('read', 'empty.txt', { first: 1, last: 1 })), diff --git a/quality/bugbot/evidence/issue-973/README.md b/quality/bugbot/evidence/issue-973/README.md new file mode 100644 index 000000000..b77c36b34 --- /dev/null +++ b/quality/bugbot/evidence/issue-973/README.md @@ -0,0 +1,40 @@ +# Deletion-only citation metadata — #973 + +The broker now excludes empty new-side intervals before testing changed-line +overlap. For `@@ -3 +2,0 @@`, the prior inverted interval `[2,1]` could label a +head citation spanning lines 1–2 as changed even though neither line was added. +The source/tree/blob, candidate, receipt and range validations are unchanged. +No finding anchor moves. + +Six controls use actual immutable Git objects and the real broker: + +| Case | Required observation | +|---|---| +| Deletion-only hunk | The adjacent unchanged head range is not changed. | +| Multiple deletion hunks | A spanning range does not acquire a false addition. | +| Real addition | The added line remains changed. | +| Mixed replacement | The new replacement line remains changed. | +| Unchanged boundary and separate addition | The boundary range remains unchanged. | +| Legitimate LEFT deletion | The original base SHA/blob/range and frozen LEFT anchor remain valid. | + +Every case also rejects a different candidate's receipt and an out-of-range +citation. The existing full shadow suite retains undelivered-receipt and tree/ +revision integrity controls. `before-fix.log.gz` records three failing metadata +cases against the original broker; the addition, replacement and LEFT controls +already passed. `initial-missing-dependency.log.gz` preserves the earlier harness +attempt that could not start before dependencies were installed; it proves no +behavioral result. + +Run `pnpm run test:bugbot-shadow-verification`. These controls make zero model +calls and zero GitHub write attempts. Old pilot artifacts, oracle labels and +scores remain unchanged. No new profile is qualified and production verification +remains disabled. Runtime bundles and final-head checks are delivery evidence, +separate from model qualification. + +Raw control logs are stored losslessly as gzip because their original reporter +whitespace fails the source diff gate. The compressed-logs.json manifest binds +each exact decompressed SHA-256 and length. Original committed attempts remain +in Git history; no log line or negative outcome has been rewritten. + +The first compression commit hook stopped when a Jest worker received SIGSEGV before the unchanged autofix suite could start (942 other suites passed). `compression-hook-worker-failure.json` and its byte-exact gzip retain that unsuccessful attempt; a focused suite check and a complete hook retry follow. +The unchanged autofix suite passes independently: 32/32 tests in one process (`compression-hook-worker-recheck.log.gz`). diff --git a/quality/bugbot/evidence/issue-973/before-fix.log.gz b/quality/bugbot/evidence/issue-973/before-fix.log.gz new file mode 100644 index 000000000..619a69414 Binary files /dev/null and b/quality/bugbot/evidence/issue-973/before-fix.log.gz differ diff --git a/quality/bugbot/evidence/issue-973/compressed-logs.json b/quality/bugbot/evidence/issue-973/compressed-logs.json new file mode 100644 index 000000000..5d27bbac9 --- /dev/null +++ b/quality/bugbot/evidence/issue-973/compressed-logs.json @@ -0,0 +1,18 @@ +{ + "encoding": "gzip", + "lossless": true, + "records": [ + { + "originalPath": "before-fix.log", + "compressedPath": "before-fix.log.gz", + "rawSha256": "b0e4e4f6defc0d184c79dbd17734f266802860d7b332e759d9cafb6626cf82b9", + "rawBytes": 3468 + }, + { + "originalPath": "initial-missing-dependency.log", + "compressedPath": "initial-missing-dependency.log.gz", + "rawSha256": "0afa6d5da501e78696051c392da214ddfaccb3d7eb42d1e2ef6404534e0bfa7b", + "rawBytes": 1880 + } + ] +} diff --git a/quality/bugbot/evidence/issue-973/compression-hook-worker-failure.json b/quality/bugbot/evidence/issue-973/compression-hook-worker-failure.json new file mode 100644 index 000000000..8e39eee4d --- /dev/null +++ b/quality/bugbot/evidence/issue-973/compression-hook-worker-failure.json @@ -0,0 +1,13 @@ +{ + "outcome": "failed", + "stage": "mandatory pre-commit Jest", + "suitesPassed": 942, + "suiteFailedToStart": "src/application/usecases/steps/commit/bugbot/__tests__/bugbot_autofix_commit.test.ts", + "signal": "SIGSEGV", + "testsPassed": 18663, + "testsSkipped": 35, + "rawSha256": "8cb3a458b0bf8402e360e3007ebad58b73815a7be4d159c1b07351cf420337a8", + "rawBytes": 531309, + "models": 0, + "realGitHubWrites": 0 +} diff --git a/quality/bugbot/evidence/issue-973/compression-hook-worker-failure.log.gz b/quality/bugbot/evidence/issue-973/compression-hook-worker-failure.log.gz new file mode 100644 index 000000000..edbc8fd52 Binary files /dev/null and b/quality/bugbot/evidence/issue-973/compression-hook-worker-failure.log.gz differ diff --git a/quality/bugbot/evidence/issue-973/compression-hook-worker-recheck.log.gz b/quality/bugbot/evidence/issue-973/compression-hook-worker-recheck.log.gz new file mode 100644 index 000000000..f8b0284db Binary files /dev/null and b/quality/bugbot/evidence/issue-973/compression-hook-worker-recheck.log.gz differ diff --git a/quality/bugbot/evidence/issue-973/initial-missing-dependency.log.gz b/quality/bugbot/evidence/issue-973/initial-missing-dependency.log.gz new file mode 100644 index 000000000..9045248e9 Binary files /dev/null and b/quality/bugbot/evidence/issue-973/initial-missing-dependency.log.gz differ diff --git a/src/infrastructure/bugbot/shadow/broker.cjs b/src/infrastructure/bugbot/shadow/broker.cjs index db5dab01e..e8d41976c 100644 --- a/src/infrastructure/bugbot/shadow/broker.cjs +++ b/src/infrastructure/bugbot/shadow/broker.cjs @@ -30,7 +30,7 @@ function intervals(patch) { return Array.from(patch.matchAll(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/gmu), match => { const start = Number(match[1]); return [start, start + Number(match[2] ?? 1) - 1]; - }); + }).filter(([start, end]) => start <= end); } function makeBroker({ repo, officialDirectory, catalog = [], localRuntime, readLocalSqlite, resolvedVersions = [], installedOfficial, readCi, pullRequest }, subject, finding, sharedRead, signal) {