11import assert from "node:assert/strict" ;
2+ import { readFileSync } from "node:fs" ;
23import test from "node:test" ;
34
45import {
@@ -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 , / P e r s i s t e n t d a t a - m o d e l c h a n g e d e t e c t e d | # # # S t o r e d d a t a m o d e l / ) ;
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