Skip to content

Stamp CLAUDE.md's Digest When It Is Written, Not Only When the Whole Install Completes #2498

Closed as not planned

Description

@ptr727

What happens

main() in host-setup/agent-safety/claude/install.py rewrites CLAUDE.md at its first stage. It writes the stamp, and with it instructionsDigest, only at its last stage. Where CLAUDE.md is rewritten completely and a later stage then fails, the stamp keeps the previous digest. The stages that can fail are hook staging, a hook self-test, and the settings write.

The file on disk is then a whole render that no stamp vouches for. Once the render changes again, for example after an edit to the host-local instructions file, --report says CLAUDE.md "was edited since the last install". The next run then backs up the installer's own render as a hand edit. That is the symptom #2454 fixes for a write cut short, reached here by a write that completed.

Shape that reproduces it

  1. Install into a throwaway CLAUDE_HOME.
  2. Change the render by adding text to the host-local file, and make a later stage fail, for example by making settings.json unwritable.
  3. Run the installer. CLAUDE.md is rewritten, and the run then fails at the settings write.
  4. Change the host-local file again, and run --report, then the installer.

The report calls the file hand-edited, and the run writes a backup of the installer's own render.

Shape of a fix

Record the new digest once CLAUDE.md is written, rather than only at the end. For example, update instructionsDigest in an existing stamp right after the write, the way #2493's record_leftover_instructions does for a leftover. Or write the stamp's instructions fields at that point and the rest at the end.

Found by the local strict review of #2493. This was confirmed by reading the code rather than by a run.

Activity

  1. added
    bug
    agents
    on Oct 7, 2026
  2. ptr727 commented on Oct 8, 2026

    @ptr727
    OwnerAuthor

    Declined under GOVERNANCE.md "Trust Boundaries and Hardening Effort" (#2501, released in 2.0.867), at the maintainer's direction. The trigger, a later install stage failing after CLAUDE.md is rewritten, fails the run loudly. Its only cost is a spurious backup of the installer's own render and one misleading --report line, and nothing is lost, so it does not meet the silent-or-destructive bar.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    agentsbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions