Skip to content

fix(hooks): bind transcript scan cache to path - #1102

Draft
KooshaPari wants to merge 7 commits into
Digital-Process-Tools:mainfrom
KooshaPari:fix/transcript-scan-identity-main
Draft

KooshaPari wants to merge 7 commits into
Digital-Process-Tools:mainfrom
KooshaPari:fix/transcript-scan-identity-main

Conversation

@KooshaPari

@KooshaPari KooshaPari commented Nov 5, 2026 •

Copy link
Copy Markdown

Summary

Two transcript files with the same basename can reuse one incremental scan cache. If both have a newline at the cached byte offset but different prefix line counts, the second scan reports the wrong line count.

Changes

  • Store the transcript path alongside the cached offset and count; recount for legacy or mismatched cache entries.
  • Publish each cache entry with a uniquely created temporary file and rename so concurrent readers do not observe a mixed entry.
  • Add collision, legacy-entry, concurrent-writer, rename-failure, and missing-cache-directory regressions; adapt existing cache-format assertions.

Test plan

  • Full pytest suite passes locally.
  • Focused identity/failure suite on 68399f9: Windows 6 passed and WSL 6 passed with --no-cov, including Unicode and spaced transcript paths.
  • Focused identity/failure suite on d46fd98: Windows 5 passed and WSL 5 passed with --no-cov, including transcript paths containing spaces.
  • Focused identity/failure suite on candidate f3ceb8b: Windows 4 passed, WSL 4 passed with --no-cov.
  • An isolated instrumented warm-scan witness confirmed each call republished its sidecar: three calls each at a81f2c8 and f3ceb8b showed one mv per call in both, plus one mktemp per call on f3ceb8b.
  • All 16 full-hook fast-path regression cases passed on f3ceb8b in isolated WSL, with the fixture home override replaced by a sandboxed Claude config path. The spawn-budget case runs under an active save cooldown and therefore does not measure scan publication.
  • Eight full post-tool stdin and timing controls passed on f3ceb8b in isolated WSL, including pretty, multibyte, empty, and 1 MiB piped payloads; 99 other cases deselected.
  • Isolated WSL scan wall-clock module on f3ceb8b: 3 passed, 1 skipped (Bash 3.2 unavailable); these bounds do not establish Windows or macOS performance.
  • Six cold-path post-tool spawn and behavior cases passed on f3ceb8b in isolated WSL (4 unrelated Git cases deselected); its spawn-budget case also uses active cooldown.
  • Incremental-scan full-hook module on f3ceb8b: 7 passed in 1.25 seconds in isolated WSL bubblewrap; fixture home override replaced with sandboxed Claude config path, environment restricted and network disabled.
  • The two affected full-hook regression modules passed in an isolated WSL copy: 18 passed, 2 Windows-only cases skipped, in 26.71 seconds. Only the fixture home override was replaced by a sandboxed Claude config path; this is not Windows evidence.
  • Focused Windows Git Bash regression: 1 passed, including 20 concurrent scans.
  • Focused WSL POSIX scan regressions: 3 passed in 26.56 seconds with --no-cov, including rename failure, missing cache directory, and concurrent writers. The last subsequent edit only renamed the new test.
  • Focused Windows rename-failure regression: 1 passed with --no-cov; the previous sidecar remains intact and the temporary file is removed.
  • Focused Windows missing-cache-directory regression: 1 passed, 2 deselected with --no-cov in 4.40 seconds; the last subsequent edit only renamed the new test.
  • Full post-tool hook witness on archived head 68399f9 in WSL bubblewrap: same-basename collision including a raw UTF-8 path with spaces, malformed cache pair recount, partial-line append completion, invalid cache name warning, injected temp-creation failure, and injected cache rename failure; old sidecar preserved and temp cleaned. Host root was read-only, network unshared, HOME and CODEX_HOME unchanged.
  • Isolated full SessionStart created its session marker; save-session --dry extracted a real test exchange without advancing last-save.json. Both ran in the same read-only-root, network-isolated WSL witness.
  • Isolated non-dry save with a stubbed local summarizer wrote now.md and advanced the session position to 2; an injected summarizer failure then preserved both and recorded a retry. A successful stubbed retry saved the later exchange once, advanced position to 4, cleared the retry marker, and a repeated empty-span save did not duplicate memory.
  • A non-dry save with a real summarizer verified.
  • Remaining hook integration and error-path tests verified.

The default focused rename-failure invocation passed its assertion but exited 1 because the 80% Python coverage floor had no Python data for this shell-only test. Also checked Bash syntax and git diff --check. An independent source review found no new blocker for distinct paths under append-only input.

Checklist

  • Changelog entry added in README.md.

This is a draft: same-path replacement or rewriting that preserves the cached newline boundary remains an existing limitation. The pre-existing hook JSON field extractor does not decode Unicode escape sequences; an isolated full-hook payload with an escaped Unicode transcript path did not publish the expected sidecar, while the raw UTF-8 form passed. In a small Fedora WSL bubblewrap sample with sidecar republication confirmed on every call (12 alternating warm calls per commit, 100-line transcript), median latency was 42.8 ms for a81f2c8 (mv only) and 49.8 ms for f3ceb8b (mktemp and mv), a 7.0 ms difference. This is not a Windows or production benchmark; the original redirect baseline and those platforms remain unmeasured. A directory concurrently writable by another process of the same user remains outside the protection established here: the temp path is reopened after creation. No hostile-directory race test was performed. Real summarizer integration and performance remain unverified; the existing integration fixtures override HOME, which was outside this validation's constraints.

tx-agent: codex

tx-validated: test
Copilot AI balanced review requested due to automatic review settings November 5, 2026 08:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

tx-agent: codex

tx-validated: test
Copilot AI balanced review requested due to automatic review settings November 5, 2026 11:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

tx-agent: codex

tx-validated: test
Copilot AI balanced review requested due to automatic review settings November 5, 2026 12:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 5, 2026 15:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

tx-agent: codex

tx-validated: test
Copilot AI balanced review requested due to automatic review settings November 5, 2026 15:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

tx-agent: codex

tx-validated: test
Copilot AI balanced review requested due to automatic review settings November 5, 2026 19:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

tx-agent: codex

tx-validated: test
Copilot AI balanced review requested due to automatic review settings November 5, 2026 19:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants