Skip to content

Harden Claude runtime state handling - #136

Closed
minislively wants to merge 3 commits into
mainfrom
fix/claude-runtime-state-resilience
Closed

Harden Claude runtime state handling#136
minislively wants to merge 3 commits into
mainfrom
fix/claude-runtime-state-resilience

Conversation

@minislively

Copy link
Copy Markdown
Owner

Summary

  • No-op unknown Claude hook event names instead of flowing them through normal prompt handling.
  • Treat corrupt Claude trust status as disconnected local state and make trust-status writes non-fatal.
  • Clean empty Claude runtime session directories after session clear/Stop.
  • Add regression tests for corrupt trust files, unknown events, session cleanup, and repeated non-stale trust state.

Verification

  • npm test
  • npm run release:smoke

Claim boundaries

  • This keeps Claude support in the project-local context-hook lane only.
  • It does not add Claude Read interception or runtime-token savings claims.

Claude hook state should fail closed instead of crashing when local runtime metadata is malformed or unexpected hook events arrive.\n\nThe runtime now no-ops unrecognized Claude hook event names, treats corrupt trust status as disconnected state, swallows trust-status write failures, and cleans empty session-state directories after Stop. Tests cover the corrupt trust file, unknown event, empty-directory cleanup, and repeated-file non-stale trust path.\n\nConstraint: Claude support remains project-local SessionStart/UserPromptSubmit context hooks only; this does not add Claude Read interception or runtime-token savings claims\nRejected: Propagate trust JSON/write failures | hook pipeline should remain non-fatal for local telemetry/state corruption\nConfidence: high\nScope-risk: narrow\nDirective: Keep Claude runtime state failures non-fatal unless a future release explicitly introduces a hard setup gate\nTested: npm test\nTested: npm run release:smoke\nNot-tested: live Claude CLI session outside isolated smoke
@Yeachan-Heo

Copy link
Copy Markdown
Collaborator

Superseded by #137 (claude-adapter-resilience). The trust-status non-stale path fix is already included in merged #137. Local main test: 220/220 pass.

…ed file

- markClaudeAttachPrepared now returns early when the same file is already
  attach-prepared, preserving lastAttachPreparedAt.
- When attach-prepared changes, lastAttachPreparedAt is initialized only if
  absent (previous.lastAttachPreparedAt ?? now()), preventing overwrite.
- Test baseline fixed: FOOKS_CLAUDE_FIRST_SEEN_INJECT=1 ensures
  lastAttachPreparedAt is set before the non-stale repeat assertion.

Fixes CI failure in PR #136.
@Yeachan-Heo Yeachan-Heo reopened this Apr 23, 2026
ensureFreshClaudeContextForTarget non-stale path test now initializes
trust status with initializeClaudeTrustStatus before reading beforeUpdatedAt.
This prevents the test from flaking when readClaudeTrustStatus returns a
fresh now() because the trust file does not yet exist.

Fixes CI failure in PR #136 (Node 20).
@Yeachan-Heo Yeachan-Heo reopened this Apr 23, 2026
@Yeachan-Heo

Copy link
Copy Markdown
Collaborator

Superseded by #140; overlapping Claude runtime/test changes already landed there. Closing to avoid duplicate merge churn.

@Yeachan-Heo
Yeachan-Heo deleted the fix/claude-runtime-state-resilience branch April 23, 2026 08:01
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