Skip to content

Commit b45a038

Browse files
committed
fix: avoid persistence warnings for test fixtures
Reuse the existing production-path scope for persistence detection so test fixture writes do not request migration proof. Preserve production, rename, semantic documentation, and unknown-evidence detection. Includes the diagnostic-only diff from openclaw/openclaw#130585 as regression evidence; the already-landed OpenGrep fix is unchanged.
1 parent f211e21 commit b45a038

4 files changed

Lines changed: 142 additions & 2 deletions

File tree

‎docs/pr-review-comments.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ review metrics, stored-data warnings, root-cause clusters, proof suggestions,
107107
merge-risk options, full review comments, labels, evidence, optional rank-up
108108
moves, the rank legend, workflow notes, and review history.
109109

110+
For OpenClaw PRs, stored-data warnings flag possible persistence changes in
111+
production source or semantic documentation changes, not setup in test,
112+
fixture, or example source paths. Renames retain evidence from either production
113+
path. Missing, empty, or truncated patches on likely production persistence paths,
114+
and truncated file lists, still produce conservative unknown warnings. The
115+
warning requests review; it does not prove a persisted contract changed.
116+
110117
Security defaults to `None.` when there are no concerns. Do not spend public
111118
space explaining why an uneventful security pass is uneventful.
112119

‎src/clawsweeper-change-detection.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ export function dataModelChangeFromContext(repo: string, context: ItemContext):
8484
const path = typeof file.filename === "string" ? file.filename.trim() : "";
8585
const previousPath =
8686
typeof file.previous_filename === "string" ? file.previous_filename.trim() : "";
87-
const candidates = [path, previousPath].filter(Boolean);
87+
// Scope each rename side before unknown handling, retaining the semantic docs branch.
88+
const candidates = [path, previousPath].filter(
89+
(candidate) => isProductionSourcePath(candidate) || isDocsPath(candidate),
90+
);
8891
const likelyPath = candidates.find(isLikelyOpenClawDataModelPath) ?? "";
8992
const patch = typeof file.patch === "string" ? file.patch : null;
9093
const lines = patch === null ? [] : changedPatchLines(patch);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"pullRequest": "https://github.com/openclaw/openclaw/pull/130585",
3+
"headSha": "7415491d399e97288a1e5c58eea8273a0d3e12e0",
4+
"pullFiles": [
5+
{
6+
"filename": "scripts/run-opengrep.sh",
7+
"additions": 1,
8+
"deletions": 3,
9+
"patch": "@@ -45,10 +45,8 @@ if ! command -v opengrep >/dev/null 2>&1; then\n cat >&2 <<'EOF'\n error: 'opengrep' not found on PATH.\n \n-Install with one of:\n+Install with:\n curl -fsSL https://raw.githubusercontent.com/opengrep/opengrep/v1.27.1/install.sh | bash -s -- -v v1.27.1\n- brew install opengrep/tap/opengrep\n- pipx install opengrep\n \n (See https://opengrep.dev for other options.)\n EOF"
10+
},
11+
{
12+
"filename": "test/scripts/run-opengrep.test.ts",
13+
"additions": 31,
14+
"deletions": 0,
15+
"patch": "@@ -42,6 +42,37 @@ function installOpengrepStub(repo: string): { argsPath: string; binDir: string }\n }\n \n describe(\"run-opengrep.sh\", () => {\n+ it(\"fails before scanning with official installation advice when opengrep is missing\", () => {\n+ const repo = createTempDir(\"openclaw-run-opengrep-missing-\");\n+ copyRunOpengrepFiles(repo);\n+ writeFile(path.join(repo, \"security/opengrep/precise.yml\"), \"rules: []\\n\");\n+\n+ const binDir = path.join(repo, \"bin\");\n+ fs.mkdirSync(binDir);\n+ for (const command of [\"bash\", \"dirname\", \"cat\"]) {\n+ const executable = execFileSync(\"bash\", [\"-c\", 'command -v \"$1\"', \"_\", command], {\n+ encoding: \"utf8\",\n+ }).trim();\n+ fs.symlinkSync(executable, path.join(binDir, command));\n+ }\n+\n+ const result = spawnSync(\n+ \"bash\",\n+ [\"scripts/run-opengrep.sh\", \"--changed\", \"--sarif\", \"--error\"],\n+ { cwd: repo, env: { ...process.env, PATH: binDir }, encoding: \"utf8\" },\n+ );\n+\n+ expect(result.status).toBe(127);\n+ expect(result.stdout).toBe(\"\");\n+ expect(result.stderr).toContain(\"'opengrep' not found on PATH\");\n+ expect(result.stderr).toMatch(\n+ /curl -fsSL https:\\/\\/raw\\.githubusercontent\\.com\\/opengrep\\/opengrep\\/\\S+\\/install\\.sh \\| bash -s -- -v \\S+/,\n+ );\n+ expect(fs.existsSync(path.join(repo, \".opengrep-out\"))).toBe(false);\n+ expect(result.stderr).not.toContain(\"pipx\");\n+ expect(result.stderr).not.toContain(\"opengrep/tap/opengrep\");\n+ });\n+\n it(\"validates the rulepack when only OpenGrep rulepack files changed\", () => {\n const repo = createTempDir(\"openclaw-run-opengrep-\");\n git(repo, \"init\", \"-q\");"
16+
}
17+
]
18+
}

‎test/pr-surface-policy.test.ts‎

Lines changed: 113 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import assert from "node:assert/strict";
2+
import { readFileSync } from "node:fs";
23
import test from "node:test";
34

45
import {
@@ -239,7 +240,99 @@ test("config surface detector fails closed for truncated pull files", () => {
239240
});
240241
});
241242

242-
test("data model detector finds persistent schema and embedding metadata changes", () => {
243+
test("tooling diagnostic and subprocess regression do not produce a stored-data warning", () => {
244+
const fixture = JSON.parse(
245+
readFileSync(new URL("./fixtures/persistence-classifier-130585.json", import.meta.url), "utf8"),
246+
);
247+
const detection = dataModelChangeFromPullFilesForTest({ pullFiles: fixture.pullFiles });
248+
249+
assert.deepEqual(detection, { change: false, surfaces: [] });
250+
251+
const comment = renderReviewCommentFromReport(
252+
`${reportFrontMatter({
253+
repository: "openclaw/openclaw",
254+
type: "pull_request",
255+
number: "130585",
256+
url: fixture.pullRequest,
257+
decision: "keep_open",
258+
close_reason: "none",
259+
work_candidate: "none",
260+
pull_head_sha: fixture.headSha,
261+
data_model_change: String(detection.change),
262+
data_model_surfaces: JSON.stringify(detection.surfaces),
263+
})}
264+
265+
## Summary
266+
267+
Corrects missing-tool installation guidance and adds a subprocess regression.
268+
`,
269+
"none",
270+
);
271+
272+
assert.doesNotMatch(comment, /Persistent data-model change detected|### Stored data model/);
273+
});
274+
275+
for (const { name, file, surfaces, pullFilesTruncated } of [
276+
{
277+
name: "colocated test serialization",
278+
file: { filename: "src/cache/store.test.ts", patch: '@@\n+writeFile("fixture.json", "{}");' },
279+
surfaces: [],
280+
},
281+
{
282+
name: "test setup with a missing patch",
283+
file: { filename: "src/cache/__tests__/setup.ts" },
284+
surfaces: [],
285+
},
286+
{
287+
name: "fixture with a truncated patch",
288+
file: {
289+
filename: "fixtures/schema.sql",
290+
patch: "@@\n+CREATE TABLE example (id TEXT);\n\n[truncated 90 chars]",
291+
},
292+
surfaces: [],
293+
},
294+
{
295+
name: "example storage setup",
296+
file: { filename: "examples/storage.ts", patch: '@@\n+await state.storage.put("key", value);' },
297+
surfaces: [],
298+
},
299+
{
300+
name: "test to production rename with a missing patch",
301+
file: { filename: "src/state.ts", previous_filename: "fixtures/state.ts" },
302+
surfaces: ["unknown-data-model-change: src/state.ts"],
303+
},
304+
{
305+
name: "production to test rename with serialization removed",
306+
file: {
307+
filename: "tests/runtime/io.ts",
308+
previous_filename: "src/runtime/io.ts",
309+
patch: "@@\n-await writeFile(target, JSON.stringify(value));",
310+
},
311+
surfaces: ["serialized state: src/runtime/io.ts"],
312+
},
313+
{
314+
name: "production to fixture rename with a missing patch",
315+
file: { filename: "fixtures/state.ts", previous_filename: "src/state.ts" },
316+
surfaces: ["unknown-data-model-change: src/state.ts"],
317+
},
318+
{
319+
name: "truncated file list containing only test setup",
320+
file: { filename: "test/setup.ts", patch: '@@\n+writeFile("fixture.json", "{}");' },
321+
pullFilesTruncated: true,
322+
surfaces: ["unknown-truncated-pull-files"],
323+
},
324+
]) {
325+
test(`data model detector scopes ${name}`, () => {
326+
const detection = dataModelChangeFromPullFilesForTest({
327+
pullFiles: [file],
328+
pullFilesTruncated,
329+
});
330+
331+
assert.deepEqual(detection, { change: surfaces.length > 0, surfaces });
332+
});
333+
}
334+
335+
test("data model detector finds production persistence and semantic docs changes in mixed diffs", () => {
243336
const detection = dataModelChangeFromPullFilesForTest({
244337
pullFiles: [
245338
{
@@ -259,15 +352,34 @@ test("data model detector finds persistent schema and embedding metadata changes
259352
filename: "packages/database/migrations/019_backfill_sessions.sql",
260353
patch: "@@\n+UPDATE sessions SET last_model = 'unknown' WHERE last_model IS NULL;",
261354
},
355+
{
356+
filename: "src/runtime/io.ts",
357+
patch: "@@\n+await writeFile(target, JSON.stringify(value));",
358+
},
359+
{
360+
filename: "src/workers/store.ts",
361+
patch: '@@\n+await state.storage.put("revision", revision);',
362+
},
363+
{
364+
filename: "docs/storage.md",
365+
patch: "@@\n+The serialized format now includes a revision field.",
366+
},
367+
{
368+
filename: "src/memory/vector-store.test.ts",
369+
patch: '@@\n+writeFile("fixture.json", JSON.stringify(value));',
370+
},
262371
],
263372
});
264373

265374
assert.deepEqual(detection, {
266375
change: true,
267376
surfaces: [
268377
"database schema: packages/database/migrations/018_sessions.sql",
378+
"durable storage schema: src/workers/store.ts",
269379
"migration/backfill/repair: packages/database/migrations/019_backfill_sessions.sql",
270380
"migration/backfill/repair: src/doctor/backfill.ts",
381+
"serialized state: docs/storage.md",
382+
"serialized state: src/runtime/io.ts",
271383
"vector/embedding metadata: src/memory/vector-store.ts",
272384
],
273385
});

0 commit comments

Comments
 (0)