Files
orca/config/scripts
Jinjing ebd4f00453 Skip reindexing unchanged transcripts on cold session list reads (#28798)
* Skip reindexing unchanged transcripts on cold session list reads

A cold session-list read re-parsed every self-contained transcript and rewrote its search rows, even when nothing had changed. That wasted work and churned the index on every list.

- When a transcript's stat (mtime, size, inode, device) matches a complete index entry, the list read now skips the rewrite. Agents with sidecar metadata, unknown sizes, or partial or stale entries still reread.
- Test fixtures that replay a "changed" transcript now pass a new mtime so they still exercise the replace path.
- New tests cover unchanged skips, changed size/mtime/file identity, sidecar refresh, due/failed repair, and append.
- Dependent-transcript and Codex title tests check that cold rereads keep search and title data current.

* Make the self-contained transcript check exhaustive over every agent

- Replace the hand-maintained `Set` of self-contained agents with a
  `Record<AiVaultAgent, boolean>`, so adding an agent type fails typecheck
  until someone decides whether its transcript is self-contained.
- Classification is unchanged: the agents that were in the set are `true`,
  and the rest are `false` with a short note on the sidecar or metadata
  source they depend on.
- Make the replace-generation tests derive the second mtime from the first
  candidate instead of a hard-coded timestamp, so they stay valid if the
  default fixture mtime changes.

* Guard file-stat reuse with a self-contained transcript test

Indexing skips reparsing unchanged transcripts for agents marked self-contained. That is only safe if their parsers read nothing but the transcript itself, and nothing enforced it. A parser that started reading a sidecar or dependency file could serve stale index entries.

- Export SELF_CONTAINED_TRANSCRIPT_AGENTS so the test checks the real list
- Add a test that parses each self-contained agent's fixture, both direct and cached, and fails if any file other than the transcript is read
- Register the test in the SQLite runtime-file include list

* Require stored file identity before skipping a transcript rewrite

- Rows with a NULL dev or ino were treated as covered, so a file replaced with the same size and mtime could be skipped and never reindexed.
- Such rows now count as uncovered, so the rewrite runs and records the identity.
- The identity is read through the shared `fileIdentity` helper instead of the raw file fields.

* Add regression test for session rows indexed without file identity

A session row indexed before file identity (dev/ino) was recorded was never reread once the stat began supplying one, so it could keep stale search content. This test covers that case: the first read with identity replaces the row, and a second read with the same identity leaves it alone.
2026-10-14 14:37:57 -07:00
..
2026-05-15 05:44:25 -04:00