Skip to content

Commit 995ab70

Browse files
authored
fix(review): stop storage warnings for test-support changes (#1314)
Recognize colocated test-support files at the shared persistence and SQLite classifier boundary while preserving production, rename, and incomplete-evidence warnings. Regress the exact 57-line fixture from openclaw/openclaw#133209; production LOC remains net zero.
1 parent 99fa190 commit 995ab70

5 files changed

Lines changed: 112 additions & 27 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ checkpoint, and status-only commits are intentionally omitted.
6464

6565
### Fixed
6666

67+
- Stopped stored-data and SQLite warnings for colocated test-support files while preserving production persistence, rename, and incomplete-evidence warnings.
6768
- Aligned PR proof comments and status labels with the existing host requirement when a reviewer records proof as not applicable, while preserving recorded assessments and merge gates.
6869
- Classified the explicitly approved autoreview fixture only by its exact full-URI digest and canonical or vendored source path, enforcing the same digest/path/mode policy at every scanned endpoint for all reviewed fixtures while preserving scanner gates and value-free audits.
6970
- Stopped treating pane-local runtime state as stored data while retaining warnings for explicit persistence changes and incomplete storage patches.

‎docs/pr-review-comments.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ or checklist.
126126

127127
For OpenClaw PRs, stored-data warnings flag possible persistence changes in
128128
production source or documented storage contracts, not setup in test, fixture,
129-
or example source paths. Markdown beside source is still documentation: ordinary
129+
or example source paths. Colocated `*.test-support.*` files are test code too,
130+
even when their guards or setup mention metadata, serialization, or SQL.
131+
Markdown beside source is still documentation: ordinary
130132
prose mentioning sessions or metadata is not a stored-format change. Explicit
131133
storage formats, SQL DDL, and structured storage keys (including frontmatter)
132134
remain evidence. Renames retain evidence from either production path. Missing,

‎src/clawsweeper-change-detection.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ function isProductionSourcePath(path: string): boolean {
212212
return false;
213213
}
214214
const basename = segments.at(-1) ?? "";
215-
return ![".spec.", ".test."].some((marker) => {
215+
return ![".spec.", ".test.", ".test-support."].some((marker) => {
216216
const markerIndex = basename.indexOf(marker);
217217
return markerIndex >= 0 && markerIndex + marker.length < basename.length;
218218
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"pullRequest": "https://github.com/openclaw/openclaw/pull/133209",
3+
"headSha": "5ce7518f720a2ce9af8ebde7642010b4083c8ecd",
4+
"sourceSha256": "97c758d403414f36efc9bd05c4e3cf05793983d46d73d291a80b4e470cbe7238",
5+
"pullFiles": [
6+
{
7+
"filename": "src/agents/embedded-agent-runner/run.workspace-ownership.test-support.ts",
8+
"status": "added",
9+
"additions": 57,
10+
"deletions": 0,
11+
"patch": "@@ -0,0 +1,57 @@\n+import { expect, vi } from \"vitest\";\n+import { isPathInside } from \"../../infra/path-guards.js\";\n+import type { OpenClawTestState } from \"../../test-utils/openclaw-test-state.js\";\n+\n+/** Guard the real consumers before discovery can touch an unowned workspace. */\n+export async function guardRunWorkspaceOwnership(\n+ state: Pick<OpenClawTestState, \"root\" | \"home\" | \"stateDir\">,\n+) {\n+ // Import after the harness reset so the spies intercept the runner's graph.\n+ const metadata = await import(\"../../plugins/plugin-metadata-snapshot.js\");\n+ const repository = await import(\"../system-prompt-params.js\");\n+ const requests: string[] = [];\n+ const forbidden: string[] = [];\n+ const check = (workspaceDir: string | undefined) => {\n+ if (workspaceDir === undefined) {\n+ return;\n+ }\n+ requests.push(workspaceDir);\n+ expect(process.env.HOME, \"fixture home survives runner reset/warmup\").toBe(state.home);\n+ expect(process.env.OPENCLAW_STATE_DIR, \"fixture state survives runner reset/warmup\").toBe(\n+ state.stateDir,\n+ );\n+ if (!isPathInside(state.root, workspaceDir)) {\n+ // Discovery can swallow filesystem errors; retain independent evidence.\n+ forbidden.push(workspaceDir);\n+ throw new Error(\"embedded-run fixture requested an unowned workspace\");\n+ }\n+ };\n+ const loadMetadata = metadata.loadPluginMetadataSnapshot;\n+ const resolveRepository = repository.resolveSystemPromptRepoRoot;\n+ const metadataSpy = vi\n+ .spyOn(metadata, \"loadPluginMetadataSnapshot\")\n+ .mockImplementation((params) => {\n+ check(params?.workspaceDir);\n+ return loadMetadata(params);\n+ });\n+ const repositorySpy = vi\n+ .spyOn(repository, \"resolveSystemPromptRepoRoot\")\n+ .mockImplementation((params) => {\n+ check(params.workspaceDir);\n+ check(params.cwd);\n+ check(params.config?.agents?.defaults?.repoRoot);\n+ return resolveRepository(params);\n+ });\n+ return {\n+ verifyAndRestore() {\n+ const metadataCalls = metadataSpy.mock.calls.length;\n+ const repositoryCalls = repositorySpy.mock.calls.length;\n+ metadataSpy.mockRestore();\n+ repositorySpy.mockRestore();\n+ expect(requests.length, \"real workspace consumer was exercised\").toBeGreaterThan(0);\n+ expect(forbidden, \"unowned workspace requests blocked before filesystem access\").toEqual([]);\n+ expect(metadataCalls, \"real metadata consumer was exercised\").toBeGreaterThan(0);\n+ expect(repositoryCalls, \"real repository consumer was exercised\").toBeGreaterThan(0);\n+ },\n+ };\n+}"
12+
}
13+
]
14+
}

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

Lines changed: 93 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,35 @@ function persistenceReport(detection: { change: boolean; surfaces: string[] }, h
3232
})}\n\n## Summary\n\nReview completed.\n\n## Review Findings\n\nOverall correctness: patch is correct\n\nOverall confidence: 0.9\n\nFull review comments:\n\n- none\n`;
3333
}
3434

35-
for (const normalized of [false, true]) {
36-
test(`pane-local diagnostics create no stored-data warning or migration gate (${normalized ? "production-normalized" : "full"} patch)`, () => {
37-
const fixture = JSON.parse(
38-
readFileSync(
39-
new URL("./fixtures/persistence-classifier-132718.json", import.meta.url),
40-
"utf8",
41-
),
42-
);
43-
const pullFiles = normalized
44-
? hydratePrimaryBody("", "pull_request", { pullFiles: fixture.pullFiles }).context.pullFiles
45-
: fixture.pullFiles;
46-
if (normalized) {
47-
assert.ok(pullFiles.some((file) => /\[truncated \d+ chars\]$/.test(file.patch)));
48-
}
49-
const detection = dataModelChangeFromPullFilesForTest({ pullFiles });
50-
const report = persistenceReport(detection, fixture.headSha);
51-
// Check the contributor-visible consequence before the classification detail.
52-
assert.doesNotMatch(
53-
renderReviewCommentFromReport(report, "none"),
54-
/Persistent data-model change detected|### Stored data model|Confirm migration/,
55-
);
56-
assert.match(reviewAutomationMarkersFromReport(report), /clawsweeper-verdict:pass/);
57-
assert.doesNotMatch(reviewAutomationMarkersFromReport(report), /needs-human|fix-required/);
58-
assert.deepEqual(detection, { change: false, surfaces: [] });
59-
});
35+
for (const [name, fixturePath] of [
36+
["pane-local diagnostics", "./fixtures/persistence-classifier-132718.json"],
37+
["test-support workspace guard", "./fixtures/persistence-classifier-133209.json"],
38+
]) {
39+
for (const normalized of [false, true]) {
40+
test(`${name} creates no stored-data warning or migration gate (${normalized ? "production-normalized" : "full"} patch)`, () => {
41+
const fixture = JSON.parse(readFileSync(new URL(fixturePath, import.meta.url), "utf8"));
42+
const pullFiles = normalized
43+
? hydratePrimaryBody("", "pull_request", { pullFiles: fixture.pullFiles }).context.pullFiles
44+
: fixture.pullFiles;
45+
if (normalized) {
46+
assert.ok(pullFiles.some((file) => /\[truncated \d+ chars\]$/.test(file.patch)));
47+
}
48+
const detection = dataModelChangeFromPullFilesForTest({ pullFiles });
49+
const report = persistenceReport(detection, fixture.headSha);
50+
// Check the contributor-visible consequence before the classification detail.
51+
assert.doesNotMatch(
52+
renderReviewCommentFromReport(report, "none"),
53+
/Persistent data-model change detected|### Stored data model|Confirm migration/,
54+
);
55+
assert.match(reviewAutomationMarkersFromReport(report), /clawsweeper-verdict:pass/);
56+
assert.doesNotMatch(reviewAutomationMarkersFromReport(report), /needs-human|fix-required/);
57+
assert.deepEqual(detection, { change: false, surfaces: [] });
58+
assert.deepEqual(sqliteSchemaChangeFromPullFilesForTest({ pullFiles }), {
59+
change: false,
60+
files: [],
61+
});
62+
});
63+
}
6064
}
6165

6266
test("runtime state names and typed parameters alone do not establish stored data", () => {
@@ -131,6 +135,21 @@ test("storage evidence still warns and gates browser, runtime, and schema change
131135
patch: "@@\n+export type Session = { lastModel?: string };",
132136
surface: "serialized state",
133137
},
138+
{
139+
filename: "src/memory/vector-store.ts",
140+
patch: "@@\n- embeddingDimension: 768,\n+ embeddingDimension: 1024,",
141+
surface: "vector/embedding metadata",
142+
},
143+
{
144+
filename: "src/db/schema.sql",
145+
patch: "@@\n+CREATE INDEX sessions_updated ON sessions(updated_at);",
146+
surface: "database schema",
147+
},
148+
{
149+
filename: "src/cache/store.ts",
150+
patch: "@@\n- ttl: 86400,\n+ ttl: 3600,",
151+
surface: "persistent cache schema",
152+
},
134153
];
135154
for (const { surface, ...file } of cases) {
136155
const pullFiles = hydratePrimaryBody("", "pull_request", { pullFiles: [file] }).context
@@ -548,6 +567,42 @@ for (const { name, file, surfaces, pullFilesTruncated } of [
548567
file: { filename: "src/cache/__tests__/setup.ts" },
549568
surfaces: [],
550569
},
570+
{
571+
name: "test support with a missing persistence patch",
572+
file: { filename: "src/cache/store.test-support.ts" },
573+
surfaces: [],
574+
},
575+
{
576+
name: "test support with a truncated schema patch",
577+
file: {
578+
filename: "src/db/schema.test-support.ts",
579+
patch: "@@\n+CREATE TABLE fixture (id TEXT);\n\n[truncated 90 chars]",
580+
},
581+
surfaces: [],
582+
},
583+
{
584+
name: "test support to production rename with a missing patch",
585+
file: {
586+
filename: "src/persistence/state.ts",
587+
previous_filename: "src/persistence/state.test-support.ts",
588+
},
589+
surfaces: ["unknown-data-model-change: src/persistence/state.ts"],
590+
},
591+
{
592+
name: "production to test support rename with stored data removed",
593+
file: {
594+
filename: "src/runtime/io.test-support.ts",
595+
previous_filename: "src/runtime/io.ts",
596+
patch: "@@\n-await writeFile(target, JSON.stringify(value));",
597+
},
598+
surfaces: ["serialized state: src/runtime/io.ts"],
599+
},
600+
{
601+
name: "truncated file list containing only test support",
602+
file: { filename: "src/cache/store.test-support.ts", patch: "@@\n+const metadata = {};" },
603+
pullFilesTruncated: true,
604+
surfaces: ["unknown-truncated-pull-files"],
605+
},
551606
{
552607
name: "fixture with a truncated patch",
553608
file: {
@@ -650,6 +705,10 @@ test("data model detector finds production persistence and semantic docs changes
650705
filename: "src/memory/vector-store.test.ts",
651706
patch: '@@\n+writeFile("fixture.json", JSON.stringify(value));',
652707
},
708+
{
709+
filename: "src/memory/vector-store.test-support.ts",
710+
patch: '@@\n+writeFile("fixture.json", JSON.stringify({ embeddingDimension: 1024 }));',
711+
},
653712
],
654713
});
655714

@@ -710,6 +769,10 @@ test("SQLite schema detector finds production table changes and ignores non-sche
710769
filename: "src/memory/manager-db.test.ts",
711770
patch: "@@\n+ db.exec('CREATE TABLE fixture_rows (id TEXT PRIMARY KEY)');",
712771
},
772+
{
773+
filename: "src/memory/manager-db.test-support.ts",
774+
patch: "@@\n+ db.exec('CREATE TABLE fixture_rows (id TEXT PRIMARY KEY)');",
775+
},
713776
{
714777
filename: "docs/storage.md",
715778
patch: "@@\n+CREATE TABLE example_rows (id TEXT PRIMARY KEY);",
@@ -733,6 +796,11 @@ test("production path classification preserves test segment and basename boundar
733796
["examples/schema.sql", false],
734797
["src/cache/store.spec.ts", false],
735798
["src/cache/store.TEST.TS", false],
799+
["src/cache/store.test-support.ts", false],
800+
["src/cache/store.TEST-SUPPORT.TS", false],
801+
["src/cache/store.test-supported.ts", true],
802+
["src/cache/store.test-support.", true],
803+
["src/store.test-support.ts/schema.sql", true],
736804
["src/spec/schema.sql", true],
737805
["src/test-fixtures/schema.sql", true],
738806
["src/cache/store.spec.", true],

0 commit comments

Comments
 (0)