1- // @effect -diagnostics nodeBuiltinImport:off - Effect's FileSystem drops NTFS file IDs above Number.MAX_SAFE_INTEGER; the raw bigint stat preserves them.
21/**
32 * AgentSessionScanner - discovery of projects a user already works on.
43 *
1413 *
1514 * @module project/AgentSessionScanner
1615 */
16+ // @effect -diagnostics-next-line nodeBuiltinImport:off - Effect's FileSystem drops NTFS file IDs above Number.MAX_SAFE_INTEGER; the raw bigint stat preserves them.
1717import * as NodeFS from "node:fs/promises" ;
1818import * as NodeOS from "node:os" ;
1919
@@ -589,7 +589,8 @@ function extractCwd(line: string): string | null {
589589 return null ;
590590}
591591
592- function transcriptIdentity (
592+ /** @public Pure helper exported for regression tests; identity construction stays beside its comparison. */
593+ export function transcriptIdentity (
593594 filePath : string ,
594595 stats : FileSystem . File . Info ,
595596 inodeRaw : string | null ,
@@ -614,9 +615,21 @@ function normalizeInodeRaw(value: unknown): string | null {
614615 return typeof value === "string" && value . length > 0 ? value : null ;
615616}
616617
617- function sameTranscriptIdentity (
618- left : ReturnType < typeof transcriptIdentity > | AgentSessionImportSource ,
619- right : ReturnType < typeof transcriptIdentity > | AgentSessionImportSource ,
618+ /** Minimal shape compared by {@link sameTranscriptIdentity}. */
619+ interface TranscriptIdentityLike {
620+ readonly filePath : string ;
621+ readonly size : number ;
622+ readonly mtimeMs : number | null ;
623+ readonly device : number ;
624+ readonly inode : number | null ;
625+ readonly inodeRaw ?: unknown ;
626+ readonly birthtimeMs : number | null ;
627+ }
628+
629+ /** @public Pure helper exported for regression tests; the Windows collision is decided here. */
630+ export function sameTranscriptIdentity (
631+ left : TranscriptIdentityLike ,
632+ right : TranscriptIdentityLike ,
620633) : boolean {
621634 if (
622635 left . filePath !== right . filePath ||
@@ -631,8 +644,8 @@ function sameTranscriptIdentity(
631644 // Records written before the raw ID existed have no `inodeRaw`; fall back
632645 // to the numeric check above so they don't re-import. When both sides
633646 // carry a raw ID (the Windows case where `inode` is `null`), it must match.
634- const leftRaw = normalizeInodeRaw ( ( left as { readonly inodeRaw ?: unknown } ) . inodeRaw ) ;
635- const rightRaw = normalizeInodeRaw ( ( right as { readonly inodeRaw ?: unknown } ) . inodeRaw ) ;
647+ const leftRaw = normalizeInodeRaw ( left . inodeRaw ) ;
648+ const rightRaw = normalizeInodeRaw ( right . inodeRaw ) ;
636649 if ( leftRaw !== null && rightRaw !== null && leftRaw !== rightRaw ) {
637650 return false ;
638651 }
0 commit comments