@feng0531/dsh-code-review 0.11.1 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # 变更记录
2
2
 
3
+ ## 0.12.0
4
+
5
+ - 多批主文件增加有界跨窗口综合,使用完整原始窗口定位目录及批准快照读取,不把目录当作源码证据。
6
+ - 综合发现必须引用至少两个不同窗口编辑,且每个引用编辑的非空旧/新侧至少一侧在本阶段read完整覆盖;保持原始定位和精确证据复核。
7
+ - 综合与局部/复核共享每文件超时、全局调用及读取额度;预检包含综合初始请求,局部覆盖和综合状态分别记录,超限/耗尽/取消不冒完成。
8
+ - 离线集成覆盖综合检索、旧新证据凭据复核、取消和预算边界;不扩权限、不证明模型结论质量,不自动升级宿主。
9
+
3
10
  ## 0.11.1
4
11
 
5
12
  - 0.11.0候选标签Windows CI发现临时目录8.3短路径与canonical长路径的测试比较差异,未触发正式发布。夹具根统一realpath,保留生产路径安全校验不放宽;原标签不移动,使用新候选。
package/README.md CHANGED
@@ -4,12 +4,16 @@
4
4
 
5
5
  ## 当前状态
6
6
 
7
- 当前代码版本为 0.11.1,包含有界覆盖预检、显式项目规则及候选证据与反证复核;发布状态以 npm 和 GitHub Release 为准。已通过真实临时 Git/SVN 仓库测试,以及隔离进程中的真实 DSH ToolRuntime 注册验证。当前开发会话的实际预览已返回0.6.0的plan/rules字段,空变更预览与默认关闭外发已验证;已进行经宿主审批的六次小规模真实试跑,累计12次模型调用;四组合成正负例与历史修复对照符合预期,历史引入方向检出候选但引用复核未完成(partial)。不是独立盲测或整体质量证明。详情见 [试跑结果](evaluation/PILOT-RESULTS.md)。
7
+ 当前代码版本为 0.12.0,包含有界覆盖预检、显式项目规则及候选证据与反证复核;发布状态以 npm 和 GitHub Release 为准。已通过真实临时 Git/SVN 仓库测试,以及隔离进程中的真实 DSH ToolRuntime 注册验证。当前开发会话的实际预览已返回0.6.0的plan/rules字段,空变更预览与默认关闭外发已验证;已进行经宿主审批的六次小规模真实试跑,累计12次模型调用;四组合成正负例与历史修复对照符合预期,历史引入方向检出候选但引用复核未完成(partial)。不是独立盲测或整体质量证明。详情见 [试跑结果](evaluation/PILOT-RESULTS.md)。
8
8
 
9
9
  ## 工作区下多个子仓库(0.11.0)
10
10
 
11
11
  当会话目录不是仓库而其子目录含Git/SVN仓库时,预览可指定 `repositoryPath`,例如会话位于工作区根时传 `{ "repositoryPath": "c3animation" }`。该参数必须是工作区相对路径(正斜杠),指向明确仓库根;不能使用绝对路径、上级路径或链接目录。文件、上下文、规则路径仍相对此次选定仓库。多个子仓库分别预览和审批执行,不混用快照;execute只接收previewId,不能另改目标。省略参数保持原行为。使用此参数需宿主安装0.11.0或更新版本;仓库发布不会自动更新当前宿主。
12
12
 
13
+ ## 跨窗口综合分析(0.12.0)
14
+
15
+ 主文件需要多批精确窗口时,在局部分析后追加一次有界综合检查。完整原始窗口目录不充当源码;综合发现必须引用至少两个不同窗口的编辑,每个引用编辑至少一个非空旧/新侧必须在本综合生成阶段被批准read完整覆盖(不能借用前批/复核审计或search)。使用原定位及证据复核,不截断规则/context。共享原每文件超时和全局调用/读取额度;预检minimumCalls包含综合初始请求,后续检索复核另计。synthesisStatus独立记录pending/completed/blocked,局部窗口完成不表示综合完成;输入超限或预算耗尽不冒算覆盖。读取覆盖及模型分析仍不证明跨路径正确性或因果事实,真实模型质量未新增验证。
16
+
13
17
  ## 修改前后对照复核(0.11.0)
14
18
 
15
19
  复核可返回 `regression`:`introduced`(模型判断本次引入)、`preexisting`(模型判断原有问题)、`uncertain`(对照不足)。前两者必须引用候选主文件旧新两侧的已精确校验证据,索引指向本候选复核 `evidence` 数组;空源或缺少任一侧时不能虚构支持。旧协议缺省标为 `unassessed`,关闭复核同样明确未评估。报告保留全部候选并展示分类、理由及 `regressionCoverage`;模型支持但对照不足进入限制。分类及引用有效不等于因果事实成立,也不宣称真实模型质量提升已获验证。去重隔离分类/理由/证据索引冲突,uncertain及unassessed不折叠。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feng0531/dsh-code-review",
3
- "version": "0.11.1",
3
+ "version": "0.12.0",
4
4
  "private": false,
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" },
@@ -14,7 +14,7 @@ export function buildCoveragePlan(input, options) {
14
14
  const item = { fileId: file.id, path: file.path, status: file.eligibility, minimumCalls: 0 };
15
15
  if (file.eligibility !== 'reviewable') return item;
16
16
  const prepared = preparePrimaryInput(input, file, options);
17
- return { ...item, ...prepared.metadata, status: prepared.budget.fits ? 'ready' : 'input-blocked', minimumCalls: prepared.budget.fits ? (prepared.batches?.length ?? 1) : 0 };
17
+ return { ...item, ...prepared.metadata, status: prepared.budget.fits ? 'ready' : 'input-blocked', minimumCalls: prepared.budget.fits ? ((prepared.batches?.length ?? 1) + (prepared.synthesis?.budget.fits ? 1 : 0)) : 0 };
18
18
  });
19
19
  return { snapshotId: input.id, maxInputBytes: options.maxInputBytes, items, minimumCalls: items.reduce((sum,item) => sum + item.minimumCalls, 0), initialRequestsOnly: true };
20
20
  }
@@ -1,4 +1,5 @@
1
1
  import { inferContextRelations } from './context-relations.mjs';
2
+ import { prepareWindowSynthesis } from './window-synthesis.mjs';
2
3
  import { planWindowBatches } from './window-batches.mjs';
3
4
  import { changeWindows } from './change-windows.mjs';
4
5
  import { changeMap } from './change-map.mjs';
@@ -16,7 +17,7 @@ export function preparePrimaryInput(input, file, { instructions, scope, grouping
16
17
  let payload = JSON.stringify(base);
17
18
  const measure = value => initialInputBudget({ instructions, input: value }, scope, maxInputBytes);
18
19
  const metadata = {};
19
- let batches;
20
+ let batches, synthesis;
20
21
  const group = grouping?.groups.find(g => g.fileIds.includes(file.id));
21
22
  if (group) {
22
23
  metadata.groupId = group.id;
@@ -53,6 +54,11 @@ export function preparePrimaryInput(input, file, { instructions, scope, grouping
53
54
  }
54
55
  }
55
56
  }
57
+ if (batches?.length > 1) {
58
+ synthesis = prepareWindowSynthesis(batches.map(batch => batch.payload), measure);
59
+ metadata.synthesisStatus = synthesis.budget.fits ? 'ready' : 'input-blocked';
60
+ metadata.synthesisInputBytes = synthesis.budget.bytes;
61
+ }
56
62
  const budget = measure(payload);
57
- return { changes, payload, batches, budget, metadata: { ...metadata, initialInputBytes: budget.bytes } };
63
+ return { changes, payload, batches, synthesis, budget, metadata: { ...metadata, initialInputBytes: budget.bytes } };
58
64
  }
package/src/review.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { validateWindowFindings } from './window-findings.mjs';
2
2
  import { groupDuplicateFindings } from './finding-groups.mjs';
3
+ import { validateSynthesisReads } from './synthesis-evidence.mjs';
3
4
  import { hash } from './content.mjs';
4
5
  import { coverageFollowup } from './coverage-followup.mjs';
5
6
  import { verificationLoop } from './verification-loop.mjs';
@@ -92,6 +93,8 @@ export async function reviewSnapshot(snapshot, model, options = {}) {
92
93
  const prepared = preparePrimaryInput(input, file, { instructions: REVIEW_INSTRUCTIONS, scope, grouping: report.grouping, maxInputBytes });
93
94
  const { changes, payload } = prepared;
94
95
  Object.assign(state, prepared.metadata);
96
+ if (prepared.synthesis) state.synthesisStatus = prepared.synthesis.budget.fits ? 'pending' : 'blocked';
97
+ if (prepared.synthesis && !prepared.synthesis.budget.fits) report.limitations.push({ fileId: file.id, text: '跨窗口综合输入超限,未发送;单窗口完成不表示交互影响已检查' });
95
98
  if (state.sourceMode === 'change-windows') state.windowCoverage = { completed: [], pending: [...state.windowIds] };
96
99
  if (changes.status === 'limited') report.limitations.push({ fileId: file.id, text: '精确变更分析受限:' + changes.reason + ';仍按完整两侧内容审查' });
97
100
  if (state.groupFallback) report.limitations.push({ fileId: file.id, text: '关联组上下文超过输入预算,回退单文件审查' });
@@ -110,12 +113,15 @@ export async function reviewSnapshot(snapshot, model, options = {}) {
110
113
  } })
111
114
  : request => { beforeCall(); return model(request); };
112
115
  await invoke(async enclosingRequest => {
113
- const batches = prepared.batches ?? [{ payload, windowIds: state.windowIds ?? [] }];
116
+ const batches = [...(prepared.batches ?? [{ payload, windowIds: state.windowIds ?? [] }])];
117
+ if (prepared.synthesis?.budget.fits) batches.push({ payload: prepared.synthesis.payload, windowIds: [], synthesis: true });
114
118
  for (const batch of batches) {
115
119
  enclosingRequest.signal.throwIfAborted();
116
120
  const request = { ...enclosingRequest, input: batch.payload };
121
+ const auditStart = state.retrievalAudit?.length ?? 0;
117
122
  const generated = validateResponse(await executor(request), file, changes);
118
- if (state.sourceMode === 'change-windows') validateWindowFindings(generated.findings, JSON.parse(batch.payload).windows);
123
+ if (batch.synthesis) validateSynthesisReads(generated.findings, changes, (state.retrievalAudit ?? []).slice(auditStart), scope.catalog(), file.id, input.id);
124
+ if (state.sourceMode === 'change-windows') validateWindowFindings(generated.findings, batch.synthesis ? prepared.synthesis.windows : JSON.parse(batch.payload).windows, batch.synthesis === true);
119
125
  request.signal.throwIfAborted();
120
126
  report.findings.push(...generated.findings);
121
127
  if (generated.findings.some(f => f.attribution.status === 'missing')) report.limitations.push({ fileId: file.id, text: '部分发现缺少变更归因,仅校验了定位,尚不能确认属于本次回归' });
@@ -138,6 +144,7 @@ export async function reviewSnapshot(snapshot, model, options = {}) {
138
144
  request.signal.throwIfAborted();
139
145
  }
140
146
  }
147
+ if (batch.synthesis) state.synthesisStatus = 'completed';
141
148
  if (state.windowCoverage) {
142
149
  state.windowCoverage.completed.push(...batch.windowIds);
143
150
  state.windowCoverage.pending = state.windowCoverage.pending.filter(id => !batch.windowIds.includes(id));
@@ -184,6 +191,7 @@ export function markdownReport(report) {
184
191
  for (const file of report.files) if (file.relatedFileIds?.length) output.push('- ' + safe(file.path) + ':输入包含 ' + file.relatedFileIds.length + ' 个关联文件');
185
192
  }
186
193
  for (const file of report.files) if (file.windowCoverage) output.push('- ' + safe(file.path) + ':变更窗口已完成 ' + file.windowCoverage.completed.length + ',待审 ' + file.windowCoverage.pending.length + ';仅表示窗口分析完成,不证明全文正确');
194
+ for (const file of report.files) if (file.synthesisStatus) output.push('- ' + safe(file.path) + ':跨窗口综合 ' + safe(file.synthesisStatus) + ';不等于事实正确性证明');
187
195
  if (report.rules?.length) output.push('', '## 项目规则', '规则仅为已批准约束数据,不扩大权限或证明缺陷。', ...report.rules.map(rule => '- ' + safe(rule.path) + ' · SHA256 ' + safe(rule.hash)));
188
196
  if (report.followup?.suggestedPaths.length) output.push('', '## 后续选择建议', '仅为原快照未完成项;不会自动续审。再次执行需新预览、新审批,并显式选择规则和上下文。阻断项需先处理原因;关联上下文不等于主文件已审查。', ...report.followup.items.filter(item => item.followup).map(item => '- ' + safe(item.path) + ':' + item.status + (item.incompleteVerification ? '(候选复核未完成)' : '')));
189
197
  output.push('', '## 审查发现');
@@ -0,0 +1,17 @@
1
+ // Audit only successful reads from this synthesis generation, never prior batches/searches.
2
+ export function validateSynthesisReads(findings, changes, reads, catalog, fileId, snapshotId) {
3
+ const sources = new Map(catalog.map(s => [s.id, s]));
4
+ for (const finding of findings) {
5
+ for (const id of finding.attribution.editIds) {
6
+ const edit = changes.edits.find(e => e.id === id);
7
+ const covered = ['old', 'new'].some(side => {
8
+ const range = edit?.[side];
9
+ return range?.count > 0 && reads.some(r => {
10
+ const source = sources.get(r.sourceId);
11
+ return r.kind === 'read' && r.snapshotId === snapshotId && source?.fileId === fileId && source.side === side && r.start <= range.start && r.start + r.count >= range.start + range.count;
12
+ });
13
+ });
14
+ if (!covered) throw new Error('Synthesis referenced edit was not read in this generation');
15
+ }
16
+ }
17
+ }
@@ -1,9 +1,10 @@
1
1
  // Called after ordinary snapshot/attribution validation, before accepting batch findings.
2
- export function validateWindowFindings(findings, windows) {
2
+ export function validateWindowFindings(findings, windows, synthesis = false) {
3
3
  const edits = new Set(windows.flatMap(w => w.editIds));
4
4
  for (const finding of findings) {
5
5
  const attribution = finding.attribution;
6
6
  if (attribution.status !== 'references-validated' || !attribution.editIds?.length || attribution.editIds.some(id => !edits.has(id))) throw new Error('Finding outside current window edits');
7
+ if (synthesis && windows.filter(w => w.editIds.some(id => attribution.editIds.includes(id))).length < 2) throw new Error('Synthesis finding must reference multiple windows');
7
8
  const anchor = finding.anchor;
8
9
  if (anchor.kind === 'line' && !windows.some(w => {
9
10
  const range = w[anchor.side];
@@ -0,0 +1,12 @@
1
+ // Pure approved-data preparation, no reads or sends. No source text is silently clipped.
2
+ export function prepareWindowSynthesis(batchPayloads, measure) {
3
+ if (!Array.isArray(batchPayloads) || batchPayloads.length < 2 || batchPayloads.length > 20) throw new Error('Invalid synthesis batches');
4
+ const batches = batchPayloads.map(payload => JSON.parse(payload));
5
+ const base = batches[0];
6
+ const windows = batches.flatMap(batch => batch.windows);
7
+ if (batches.some(batch => batch.snapshotId !== base.snapshotId || batch.file.id !== base.file.id || batch.sourceMode !== 'change-windows') || windows.length > 200 || new Set(windows.map(w => w.id)).size !== windows.length) throw new Error('Inconsistent synthesis windows');
8
+ const windowIndex = windows.map(w => ({ id: w.id, editIds: w.editIds, old: { start: w.old.start, count: w.old.count }, new: { start: w.new.start, count: w.new.count } }));
9
+ const payload = JSON.stringify({ ...base, windows: undefined, windowIndex, sourceMode: 'window-synthesis', windowNotice: '本请求综合检查所有窗口的共同影响,不重报单窗口问题;windowIndex仅为原始定位目录,不含源码,必须在批准catalog中读取相关旧新片段,不能仅凭目录认定缺陷。输出仍仅主file的发现,归因至少关联两个不同窗口的编辑;证据不足明确限制。' });
10
+ const budget = measure(payload);
11
+ return { payload, windows, windowIds: windows.map(w => w.id), budget };
12
+ }