@@ -18,18 +18,18 @@ import {
1818 runOpenClawAgentWriteTransaction ,
1919} from "../../state/openclaw-agent-db.js" ;
2020import { readSessionTranscriptMessageEvents } from "./session-accessor.sqlite-active-events.js" ;
21- import { materializeSqliteSessionStateDeletePlans } from "./session-accessor.sqlite-archive.js" ;
21+ import { materializeSessionStateDeletePlans } from "./session-accessor.sqlite-archive.js" ;
2222import { writeSessionEntry } from "./session-accessor.sqlite-entry-store.js" ;
23- import { planSqliteSessionStateDeleteIfUnreferenced } from "./session-accessor.sqlite-lifecycle-state.js" ;
23+ import { planSessionStateDeleteIfUnreferenced } from "./session-accessor.sqlite-lifecycle-state.js" ;
2424import {
25- loadLatestSqliteAssistantText ,
26- loadSqliteTranscriptEventsSync ,
27- loadSqliteTranscriptTailEventsSync ,
25+ loadLatestAssistantText ,
26+ loadTranscriptEventsSync ,
27+ loadTranscriptTailEventsSync ,
2828} from "./session-accessor.sqlite-read.js" ;
2929import { readActiveTranscriptAppendParentId } from "./session-accessor.sqlite-transcript-store.js" ;
3030import {
31- appendSqliteTranscriptMessage ,
32- trimSqliteTranscriptForManualCompact ,
31+ appendTranscriptMessage ,
32+ trimTranscriptForManualCompact ,
3333} from "./session-accessor.sqlite-transcript-write.js" ;
3434import {
3535 readAuthorizedTranscriptEventSeqs ,
@@ -132,7 +132,7 @@ async function appendWithRun(params: { env: NodeJS.ProcessEnv; runId: string; te
132132 withTranscriptWrite : async ( run ) => await run ( ) ,
133133 } ,
134134 async ( ) => {
135- await appendSqliteTranscriptMessage ( scope ( params . env ) , {
135+ await appendTranscriptMessage ( scope ( params . env ) , {
136136 message : { role : "assistant" , content : [ { type : "text" , text : params . text } ] } ,
137137 } ) ;
138138 } ,
@@ -175,7 +175,7 @@ describe("transcript memory policy companions", () => {
175175 if ( aliceContext . kind !== "current" ) {
176176 throw new Error ( "expected lifecycle-owned Alice subject context" ) ;
177177 }
178- await appendSqliteTranscriptMessage (
178+ await appendTranscriptMessage (
179179 { ...alice , agentId : AGENT_ID , env } ,
180180 {
181181 message : {
@@ -237,7 +237,7 @@ describe("transcript memory policy companions", () => {
237237 withTranscriptWrite : async ( run ) => await run ( ) ,
238238 } ,
239239 async ( ) => {
240- await appendSqliteTranscriptMessage (
240+ await appendTranscriptMessage (
241241 { ...alice , agentId : AGENT_ID , env } ,
242242 {
243243 message : {
@@ -251,7 +251,7 @@ describe("transcript memory policy companions", () => {
251251 expect ( readAuthorizedTranscriptEventSeqs ( database . db , alice . sessionId ) ?. size ) . toBeGreaterThan (
252252 0 ,
253253 ) ;
254- expect ( loadSqliteTranscriptEventsSync ( { ...alice , agentId : AGENT_ID , env } ) ) . toContainEqual (
254+ expect ( loadTranscriptEventsSync ( { ...alice , agentId : AGENT_ID , env } ) ) . toContainEqual (
255255 expect . objectContaining ( {
256256 message : expect . objectContaining ( {
257257 content : [ { type : "text" , text : "alice scoped content" } ] ,
@@ -270,26 +270,26 @@ describe("transcript memory policy companions", () => {
270270 expect ( createCurrentMemorySessionContext ( { ...bob , options } ) ) . toEqual ( {
271271 kind : "shadow-subject-mismatch" ,
272272 } ) ;
273- await appendSqliteTranscriptMessage (
273+ await appendTranscriptMessage (
274274 { ...bob , agentId : AGENT_ID , env } ,
275275 {
276276 message : { role : "assistant" , content : [ { type : "text" , text : "bob denied content" } ] } ,
277277 } ,
278278 ) ;
279279 expect ( readAuthorizedTranscriptEventSeqs ( database . db , bob . sessionId ) ) . toEqual ( new Set ( ) ) ;
280- expect ( loadSqliteTranscriptEventsSync ( { ...bob , agentId : AGENT_ID , env } ) ) . toEqual ( [ ] ) ;
280+ expect ( loadTranscriptEventsSync ( { ...bob , agentId : AGENT_ID , env } ) ) . toEqual ( [ ] ) ;
281281 } ) ;
282282
283283 it ( "fails closed for missing or stale run exposure while indexing only an authorized event" , async ( ) => {
284284 const env = createEnv ( ) ;
285285 // Establish the SQLite session before the cut-over marker is written; its old row has no
286286 // companion and must disappear as soon as the enforced policy reader is active.
287- await appendSqliteTranscriptMessage ( scope ( env ) , {
287+ await appendTranscriptMessage ( scope ( env ) , {
288288 message : { role : "assistant" , content : [ { type : "text" , text : "legacy private content" } ] } ,
289289 } ) ;
290290 const database = markCutOver ( env ) ;
291291
292- await appendSqliteTranscriptMessage ( scope ( env ) , {
292+ await appendTranscriptMessage ( scope ( env ) , {
293293 message : { role : "assistant" , content : [ { type : "text" , text : "missing exposure content" } ] } ,
294294 } ) ;
295295 persistExposure ( database , { runId : "stale-run" , subjectRevision : "stale-subject-revision" } ) ;
@@ -320,21 +320,21 @@ describe("transcript memory policy companions", () => {
320320 ) ;
321321
322322 expect ( readAuthorizedTranscriptEventSeqs ( database . db , SESSION_ID ) ) . toEqual ( new Set ( [ 4 ] ) ) ;
323- expect ( loadSqliteTranscriptEventsSync ( scope ( env ) ) ) . toEqual ( [
323+ expect ( loadTranscriptEventsSync ( scope ( env ) ) ) . toEqual ( [
324324 expect . objectContaining ( {
325325 message : expect . objectContaining ( {
326326 content : [ { type : "text" , text : "authorized exposure content" } ] ,
327327 } ) ,
328328 } ) ,
329329 ] ) ;
330- expect ( loadSqliteTranscriptTailEventsSync ( scope ( env ) , 2 ) ) . toEqual ( [
330+ expect ( loadTranscriptTailEventsSync ( scope ( env ) , 2 ) ) . toEqual ( [
331331 expect . objectContaining ( {
332332 message : expect . objectContaining ( {
333333 content : [ { type : "text" , text : "authorized exposure content" } ] ,
334334 } ) ,
335335 } ) ,
336336 ] ) ;
337- expect ( loadLatestSqliteAssistantText ( scope ( env ) ) ) . toMatchObject ( {
337+ expect ( loadLatestAssistantText ( scope ( env ) ) ) . toMatchObject ( {
338338 text : "authorized exposure content" ,
339339 } ) ;
340340
@@ -377,13 +377,13 @@ describe("transcript memory policy companions", () => {
377377 } ,
378378 async ( ) => {
379379 authorizedMessageId = (
380- await appendSqliteTranscriptMessage ( scope ( env ) , {
380+ await appendTranscriptMessage ( scope ( env ) , {
381381 message : { role : "assistant" , content : [ { type : "text" , text : "authorized" } ] } ,
382382 } )
383383 ) . messageId ;
384384 } ,
385385 ) ;
386- const pending = await appendSqliteTranscriptMessage ( scope ( env ) , {
386+ const pending = await appendTranscriptMessage ( scope ( env ) , {
387387 message : { role : "assistant" , content : [ { type : "text" , text : "pending" } ] } ,
388388 } ) ;
389389
@@ -394,13 +394,13 @@ describe("transcript memory policy companions", () => {
394394 it ( "does not pass a pending transcript event to manual compaction" , async ( ) => {
395395 const env = createEnv ( ) ;
396396 const database = markCutOver ( env ) ;
397- await appendSqliteTranscriptMessage ( scope ( env ) , {
397+ await appendTranscriptMessage ( scope ( env ) , {
398398 message : { role : "assistant" , content : [ { type : "text" , text : "pending" } ] } ,
399399 } ) ;
400400 const selectRetainedLines = vi . fn ( ( ) => null ) ;
401401
402402 await expect (
403- trimSqliteTranscriptForManualCompact ( scope ( env ) , selectRetainedLines ) ,
403+ trimTranscriptForManualCompact ( scope ( env ) , selectRetainedLines ) ,
404404 ) . resolves . toEqual ( { trimmed : false } ) ;
405405
406406 expect ( selectRetainedLines ) . not . toHaveBeenCalled ( ) ;
@@ -480,7 +480,7 @@ describe("transcript memory policy companions", () => {
480480 expect ( readAuthorizedTranscriptEventSeqs ( fresh . db , SESSION_ID ) ?. size ) . toBe (
481481 committedAuthorizedCount ,
482482 ) ;
483- expect ( loadSqliteTranscriptEventsSync ( scope ( env ) ) ) . toContainEqual (
483+ expect ( loadTranscriptEventsSync ( scope ( env ) ) ) . toContainEqual (
484484 expect . objectContaining ( {
485485 message : expect . objectContaining ( {
486486 content : [ { type : "text" , text : "committed companion content" } ] ,
@@ -490,15 +490,15 @@ describe("transcript memory policy companions", () => {
490490
491491 // A later durable row without a companion is pending. A separate database
492492 // consumer must not infer authority from the earlier committed exposure.
493- await appendSqliteTranscriptMessage ( scope ( env ) , {
493+ await appendTranscriptMessage ( scope ( env ) , {
494494 message : { role : "assistant" , content : [ { type : "text" , text : "missing companion" } ] } ,
495495 } ) ;
496496 closeOpenClawAgentDatabasesForTest ( ) ;
497497 fresh = openOpenClawAgentDatabase ( { agentId : AGENT_ID , env } ) ;
498498 expect ( readAuthorizedTranscriptEventSeqs ( fresh . db , SESSION_ID ) ?. size ) . toBe (
499499 committedAuthorizedCount ,
500500 ) ;
501- expect ( loadSqliteTranscriptEventsSync ( scope ( env ) ) ) . toContainEqual (
501+ expect ( loadTranscriptEventsSync ( scope ( env ) ) ) . toContainEqual (
502502 expect . objectContaining ( {
503503 message : expect . objectContaining ( {
504504 content : [ { type : "text" , text : "committed companion content" } ] ,
@@ -519,7 +519,7 @@ describe("transcript memory policy companions", () => {
519519 expect ( readAuthorizedTranscriptEventSeqs ( fresh . db , SESSION_ID ) ?. size ) . toBe (
520520 committedAuthorizedCount ,
521521 ) ;
522- expect ( loadSqliteTranscriptEventsSync ( scope ( env ) ) ) . toContainEqual (
522+ expect ( loadTranscriptEventsSync ( scope ( env ) ) ) . toContainEqual (
523523 expect . objectContaining ( {
524524 message : expect . objectContaining ( {
525525 content : [ { type : "text" , text : "committed companion content" } ] ,
@@ -539,7 +539,7 @@ describe("transcript memory policy companions", () => {
539539 closeOpenClawAgentDatabasesForTest ( ) ;
540540 fresh = openOpenClawAgentDatabase ( { agentId : AGENT_ID , env } ) ;
541541 expect ( readAuthorizedTranscriptEventSeqs ( fresh . db , SESSION_ID ) ) . toEqual ( new Set ( ) ) ;
542- expect ( loadSqliteTranscriptEventsSync ( scope ( env ) ) ) . toEqual ( [ ] ) ;
542+ expect ( loadTranscriptEventsSync ( scope ( env ) ) ) . toEqual ( [ ] ) ;
543543 } ) ;
544544
545545 it ( "removes a stale companion from replay, search, projections, compaction, and export" , async ( ) => {
@@ -565,16 +565,16 @@ describe("transcript memory policy companions", () => {
565565 . run ( 999 , SESSION_ID ) ;
566566
567567 expect ( readAuthorizedTranscriptEventSeqs ( database . db , SESSION_ID ) ) . toEqual ( new Set ( ) ) ;
568- expect ( loadSqliteTranscriptEventsSync ( scope ( env ) ) ) . toEqual ( [ ] ) ;
568+ expect ( loadTranscriptEventsSync ( scope ( env ) ) ) . toEqual ( [ ] ) ;
569569 expect ( search ( ) . hits ) . toEqual ( [ ] ) ;
570570 expect ( ( ) => readSessionTranscriptMessageEvents ( scope ( env ) ) ) . toThrow (
571571 / p r o j e c t i o n i s r e b u i l d i n g / i,
572572 ) ;
573- await expect ( trimSqliteTranscriptForManualCompact ( scope ( env ) , vi . fn ( ) ) ) . resolves . toEqual ( {
573+ await expect ( trimTranscriptForManualCompact ( scope ( env ) , vi . fn ( ) ) ) . resolves . toEqual ( {
574574 trimmed : false ,
575575 } ) ;
576576
577- const plan = planSqliteSessionStateDeleteIfUnreferenced ( {
577+ const plan = planSessionStateDeleteIfUnreferenced ( {
578578 archiveDirectory : path . join ( roots . at ( - 1 ) ?? "" , "archives" ) ,
579579 archiveTranscript : true ,
580580 database,
@@ -583,7 +583,7 @@ describe("transcript memory policy companions", () => {
583583 sessionId : SESSION_ID ,
584584 } ) ;
585585 expect ( plan ) . not . toBeNull ( ) ;
586- const materialized = await materializeSqliteSessionStateDeletePlans ( [ plan ! ] ) ;
586+ const materialized = await materializeSessionStateDeletePlans ( [ plan ! ] ) ;
587587 expect ( materialized [ 0 ] ?. archivedTranscript ) . toBeNull ( ) ;
588588 } ) ;
589589} ) ;
0 commit comments