repair

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package repair fixes the modification time of session files that were imported with a "wrong" (import-time) mtime, which makes a coding agent's index see them as newer than indexed and re-parse them on every open (Codex read-repair), a multi-second delay each time.

It resets each affected file's mtime to the latest timestamp recorded INSIDE the session (its real last-activity time). It only ever changes file modification times — it never edits session content and never touches any index/SQLite — so it is safe to run repeatedly and is a no-op for files that are already correct.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileResult

type FileResult struct {
	Path        string
	ContentTime time.Time // latest timestamp found inside the file (the new mtime)
	OldMtime    time.Time
}

FileResult is the outcome for one fixed (or, in dry-run, would-be-fixed) file.

type Options

type Options struct {
	// DryRun reports what would change without touching any file.
	DryRun bool
	// MinGap is the minimum amount by which a file's mtime must exceed its
	// content's last timestamp before it is considered worth fixing. It avoids
	// touching native files whose mtime already matches their content.
	MinGap time.Duration
}

Options configures a repair pass.

type Result

type Result struct {
	Scanned  int
	Fixed    int
	Files    []FileResult
	Warnings []string
	DryRun   bool
}

Result summarizes a repair pass. Fixed counts the candidate files whose mtime was reset (or, in DryRun, would be reset).

func RepairTimes

func RepairTimes(dirs []string, opts Options) (Result, error)

RepairTimes walks the given directories for plain *.jsonl session files and, for each whose on-disk mtime is more than opts.MinGap later than the newest timestamp recorded inside it, resets the mtime to that content timestamp. Compressed (.jsonl.zst) files are skipped (their content is not read here).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL