@@ -165,7 +165,7 @@ describe("readFileBounded", () => {
165165 expect ( content ) . not . toContain ( "continue" ) ;
166166 } ) ;
167167
168- test ( "a newline-less file past the scan ceiling returns content , not empty" , async ( ) => {
168+ test ( "a newline-less file past the scan ceiling returns a windowed page , not empty" , async ( ) => {
169169 const giant = "a" . repeat ( READ_FILE_MAX_SCAN_BYTES + 1024 ) ;
170170 const p = await fixture ( "giant-line.txt" , giant ) ;
171171 const { content, isError } = await readFileBounded (
@@ -177,7 +177,21 @@ describe("readFileBounded", () => {
177177 expect ( isError ) . toBeUndefined ( ) ;
178178 expect ( content . length ) . toBeGreaterThan ( 0 ) ;
179179 expect ( content ) . toContain ( " 1\t" ) ;
180- expect ( content ) . toContain ( "scan limit" ) ;
180+ // The scan-capped remainder is windowed like a smaller overlong line, so
181+ // the footer offers a deliverable offset page instead of a truncated line
182+ // under a scan notice whose tail is unreachable.
183+ expect ( content ) . not . toContain ( "line truncated" ) ;
184+ expect ( content ) . not . toContain ( "scan limit" ) ;
185+ expect ( content ) . toContain ( "output limit" ) ;
186+ expect ( content ) . toContain ( "Use offset=" ) ;
187+ const body = content . split ( "\n\n" ) [ 0 ] ?? "" ;
188+ const numbered = body . trimEnd ( ) . split ( "\n" ) ;
189+ expect ( numbered . length ) . toBeGreaterThan ( 1 ) ;
190+ for ( const line of numbered ) {
191+ expect ( line . replace ( / ^ \s * \d + \t / , "" ) . length ) . toBeLessThanOrEqual (
192+ READ_FILE_MAX_LINE_LENGTH ,
193+ ) ;
194+ }
181195 } ) ;
182196
183197 test ( "abort rejects with read_file timeout guidance" , async ( ) => {
@@ -446,6 +460,37 @@ describe("CL-8979 large-file pagination", () => {
446460 expect ( collected ) . toContain ( "END" ) ;
447461 } ) ;
448462
463+ test ( "windows a single file line past the scan ceiling with exact reassembly" , async ( ) => {
464+ const filler = "0123456789ABCDEF" . repeat (
465+ Math . ceil ( ( READ_FILE_MAX_SCAN_BYTES + 4096 ) / 16 ) ,
466+ ) ;
467+ const payload = `HEAD-${ filler } -TAIL` ;
468+ expect ( payload . length ) . toBeGreaterThan ( READ_FILE_MAX_SCAN_BYTES ) ;
469+ const p = await fixture ( "cl8979-scan-giant.txt" , `${ payload } \nEND\n` ) ;
470+ const rows : string [ ] = [ ] ;
471+ let offset = 0 ;
472+ let hops = 0 ;
473+ for ( ; ; ) {
474+ const res = await readFileBounded ( p , offset , 2000 , neverAbort ( ) ) ;
475+ hops += 1 ;
476+ expect ( res . isError ) . toBeUndefined ( ) ;
477+ const content = String ( res . content ) ;
478+ // No silent tail loss: every scanned byte is windowed, never truncated,
479+ // and no footer promises continuation it cannot deliver.
480+ expect ( content ) . not . toContain ( "line truncated" ) ;
481+ expect ( content ) . not . toContain ( "scan limit" ) ;
482+ rows . push ( ...bodyRows ( content ) ) ;
483+ const next = continueOffset ( content ) ;
484+ if ( next === null ) break ;
485+ expect ( next ) . toBeGreaterThan ( offset ) ;
486+ offset = next ;
487+ expect ( hops ) . toBeLessThan ( 500 ) ;
488+ }
489+ expect ( hops ) . toBeGreaterThan ( 1 ) ;
490+ expect ( rows [ rows . length - 1 ] ) . toBe ( "END" ) ;
491+ expect ( rows . slice ( 0 , - 1 ) . join ( "" ) ) . toBe ( payload ) ;
492+ } , 180_000 ) ;
493+
449494 test ( "a large-file page passes the result-truncation layer byte-identical" , async ( ) => {
450495 const name = "cl8979-page.txt" ;
451496 const rows = Array . from (
0 commit comments