Skip to content

Hot memory: send each checkpoint once per session; checkpoint wording - #50

Merged
jbwinters merged 7 commits into
mainfrom
feat/hot-injection-dedup
Nov 29, 2026
Merged

jbwinters merged 7 commits into
mainfrom
feat/hot-injection-dedup

Conversation

@jbwinters

@jbwinters jbwinters commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Task Master 162 and 165 (items 1, 3, 4), from the 2026-11-23 research review.

Problem. Claude Code and Codex sessions received the top hot checkpoint on every prompt, even when it shared no words with the prompt. The same excerpt and the ~600-character capture contract were repeated every turn.

Changes (162)

  • Per host session, a local record of the checkpoint digests the session has received (one file per session under state/context-delivery/, never synced). A checkpoint the session already holds is not sent again. Compaction (PreCompact, PostCompact, SessionStart compact, including Claude Code auto-compaction), a changed checkpoint, or 25 prompts without a reset send it again.
  • A session that holds nothing (first prompt, after compaction) gets every selected checkpoint in full, as before. After that, a checkpoint that shares no terms with the prompt is reduced to one line naming its request plus the page and search commands.
  • A session's own checkpoints are not sent back to it until compaction.
  • The capture contract is sent only when the session holds nothing.
  • Within an entry, superseded earlier findings come first and the latest finding last, labelled with its time. Entry order is unchanged (priority order keeps imports on page 1).
  • Other hosts (pi, hermes, opencode, agy) are unchanged.

Changes (165)

  • Compaction ranks unresolved / blocked / remaining sentences as important.
  • The capture contract asks that a check reported as passed name the command, working directory, commit and dirty state, and that saved statuses be rechecked live.
  • The prior-findings guidance is one conditional sentence per conflict case.

Not in this PR: the Codex 1-vs-3 inlined pages comparison and the benchmark non-inferiority check (both need the paid task 161 pilot), and the separate Unresolved: field (165 item 2, waits on 161).

Verification: vitest run on Node 22.23.4: 80 files, 702 tests pass (origin/main baseline 688/688). New tests in tests/runtime/hot-delivery.test.ts. An independent review found four defects (pointer on a lost start claim, a cross-session reset race, the history header cutting the latest finding, and evicted pointer keys); all are fixed in 0d5a303 with tests.

Update (6a413a0). Delivery now also resets on every SessionStart (startup, resume, clear, fork) in both hooks. A new end-to-end test, tests/runtime/hot-delivery-hooks.test.ts, drives the installed hook commands against a real daemon on both hosts:

  1. the first prompt delivers the checkpoint;
  2. a repeat prompt delivers nothing;
  3. an automatic PreCompact causes a redelivery;
  4. a later SessionStart causes a redelivery.

Full suite: 81 files, 703 tests pass.

Claude Code and Codex sessions received the top hot checkpoint on every
prompt, even when it shared no words with the prompt, and the same excerpt
and the ~600-character capture contract were repeated each turn.

- Record per host session which checkpoint digests it received (local
  state only). A checkpoint the session already holds is not sent again;
  PreCompact, PostCompact, SessionStart(compact), a changed checkpoint or
  25 prompts without a reset send it again.
- After the first prompt, a checkpoint that shares no terms with the
  prompt is reduced to one line naming its request and the page command.
- The capture contract is sent only when the session holds no earlier
  delivery (first prompt, after compaction).
- Within an entry, superseded earlier findings come first and the latest
  finding last, labelled with its time.

Other hosts are unchanged. Task Master 162.
…te precedence as conditions

- Summary compaction now ranks sentences about unresolved, blocked or
  remaining work as important, so they survive when a finding is cut.
- The capture contract asks that a check reported as passed name the
  command, working directory, commit and dirty state, and that a saved
  status (tests, CI, review, mergeability) be checked again before use.
- The prior-findings guidance is written as one conditional sentence per
  conflict case: current message, what the agent sees now, and other
  saved findings.

The separate 'Unresolved:' field waits on the task 161 headroom pilot.
Task Master 165 (items 1, 3, 4).
…ng, per-session files

From an independent review:
- Pointer vs full is decided by whether the session holds any delivery,
  not by the start claim, so a lost claim, an auto-compaction or a racing
  hook process still gets the full checkpoint.
- One delivery file per host session. A compaction reset deletes it, so
  another session's concurrent write cannot restore the stale record.
- A session's own checkpoints are not sent back to it until compaction.
- The earlier-findings header is written only when a finding fits under
  it, so the latest finding is never cut to make room.
- A pointer also names the search command, in case its page key has been
  evicted.
A started, resumed, cleared or forked session holds none of what a reused
session id recorded, so SessionStart resets that session's delivery in
both hooks (a false reset costs one repeat).

New test drives the installed hook commands against a real daemon on
both hosts: first prompt delivers, a repeat does not, automatic
PreCompact and a later SessionStart deliver again.
…y after rendering

From the completion review:
- With newest-last ordering the oldest earlier finding took the history
  budget first. Budget now goes newest first; text still reads oldest
  to newest, then the latest finding.
- The per-session delivery record is written after the text is built,
  so a failure while rendering never marks an unsent checkpoint as
  delivered.
@jbwinters
jbwinters merged commit e5943c9 into main Nov 29, 2026
10 of 11 checks passed
jbwinters added a commit that referenced this pull request Nov 29, 2026
* Send each hot checkpoint once per session; point to unrelated ones

Claude Code and Codex sessions received the top hot checkpoint on every
prompt, even when it shared no words with the prompt, and the same excerpt
and the ~600-character capture contract were repeated each turn.

- Record per host session which checkpoint digests it received (local
  state only). A checkpoint the session already holds is not sent again;
  PreCompact, PostCompact, SessionStart(compact), a changed checkpoint or
  25 prompts without a reset send it again.
- After the first prompt, a checkpoint that shares no terms with the
  prompt is reduced to one line naming its request and the page command.
- The capture contract is sent only when the session holds no earlier
  delivery (first prompt, after compaction).
- Within an entry, superseded earlier findings come first and the latest
  finding last, labelled with its time.

Other hosts are unchanged. Task Master 162.

* Checkpoint wording: keep open items, tie passed checks to a tree, state precedence as conditions

- Summary compaction now ranks sentences about unresolved, blocked or
  remaining work as important, so they survive when a finding is cut.
- The capture contract asks that a check reported as passed name the
  command, working directory, commit and dirty state, and that a saved
  status (tests, CI, review, mergeability) be checked again before use.
- The prior-findings guidance is written as one conditional sentence per
  conflict case: current message, what the agent sees now, and other
  saved findings.

The separate 'Unresolved:' field waits on the task 161 headroom pilot.
Task Master 165 (items 1, 3, 4).

* Hot delivery review fixes: full checkpoint when a session holds nothing, per-session files

From an independent review:
- Pointer vs full is decided by whether the session holds any delivery,
  not by the start claim, so a lost claim, an auto-compaction or a racing
  hook process still gets the full checkpoint.
- One delivery file per host session. A compaction reset deletes it, so
  another session's concurrent write cannot restore the stale record.
- A session's own checkpoints are not sent back to it until compaction.
- The earlier-findings header is written only when a finding fits under
  it, so the latest finding is never cut to make room.
- A pointer also names the search command, in case its page key has been
  evicted.

* Checkpoints record git state and warn when shown in a tree that differs

Hot checkpoints carried no HEAD, branch, dirty or untracked-file state,
and captured command output carried no revision, so a session in another
checkout or after the tree moved trusted results observed on other bytes.

- Evidence captured at Stop, PreCompact and PostToolUse records the
  workspace's git state (one 'git status --porcelain=v2', 1.5 s timeout,
  no optional locks; untracked files hashed, at most 20, private names
  skipped). Command output is stamped with the commit it ran at.
- Rendering compares with the reader's tree: one 'Workspace drift' line
  when HEAD, branch, uncommitted state or untracked files differ; file
  excerpts no longer on disk or changed are marked; command output run
  at another commit is marked. Same checkout: nothing.
- Sources dropped to fit a bound keep their name and digest and are
  listed as not kept.
- The field is optional inside the opaque evidence: older clients drop
  it, sync budget unchanged. Warning only; nothing is restored.

Handoff capsules do not carry git state yet. Task Master 164.

* Git state review fixes: no false drift, contained reads, bounded size and latency

From an independent review:
- Only sources that plainly name a file (a path, or one cat/head/tail/sed
  read) are checked on disk; command-named reads were always 'missing'.
- An untracked entry captured without a hash (symlink, large or
  unreadable file) is checked for presence only.
- Synced untracked paths must be workspace-relative (no '..', absolute
  or NUL); reads lstat first, open with O_NOFOLLOW|O_NONBLOCK, require a
  regular file and check realpath containment, so a FIFO cannot block a
  hook and a symlink cannot read outside the workspace.
- Metadata is bounded (10 untracked, 8 dropped names, 160-char paths) and
  is dropped before any excerpt when a checkpoint is over budget.
- git status uses -unormal; drift and file checks are computed once per
  prompt; the drift line is capped at 320 characters.
- The private-name filter covers more secret-like names.

* Reset checkpoint delivery on every session start; end-to-end hook test

A started, resumed, cleared or forked session holds none of what a reused
session id recorded, so SessionStart resets that session's delivery in
both hooks (a false reset costs one repeat).

New test drives the installed hook commands against a real daemon on
both hosts: first prompt delivers, a repeat does not, automatic
PreCompact and a later SessionStart deliver again.

* History budget favors the most recent earlier finding; record delivery after rendering

From the completion review:
- With newest-last ordering the oldest earlier finding took the history
  budget first. Budget now goes newest first; text still reads oldest
  to newest, then the latest finding.
- The per-session delivery record is written after the text is built,
  so a failure while rendering never marks an unsent checkpoint as
  delivered.

* Handoff capsules carry the exporting workspace's git state; slow-git and round-trip tests

- Export records continuityIr.provenance.workspace (head, branch, dirty,
  filtered untracked names) for the exporting workspace. The field is
  optional and signed with the capsule; older importers ignore it.
- Import attaches it as evidence on the imported checkpoint, so opening
  the handoff in a different tree shows the drift line.
- Tests: export and import through the lifecycle engine, a git that
  hangs (null within the timeout), and a synced document with git state
  that the wire validator accepts unchanged.

* Capsule git state: opt-in for host handoff export only; no file names

From a fresh review: every capsule, including deal handoffs uploaded to
a counterparty, carried branch, HEAD, dirty state and untracked file
names with content hashes.

- Only the Claude Code and Codex handoff export opts in; deal handoffs
  and other callers never carry it.
- A capsule carries commit, branch and dirty state only: no untracked
  names or hashes leave the machine. Hot sync (own devices) is unchanged.

* Give the redelivery-interval test 30 s: it drives about 30 prompts and took 6.9 s on CI's Node 24 runner
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.

1 participant