Skip to content

test(claude): verify interleaved host writes persist separately - #1483

Merged
dnlrsls merged 2 commits into
Gentleman-Programming:mainfrom
dnlrsls:test/1270-claude-persistence-main
Sep 28, 2026
Merged

dnlrsls merged 2 commits into
Gentleman-Programming:mainfrom
dnlrsls:test/1270-claude-persistence-main

Conversation

@dnlrsls

@dnlrsls dnlrsls commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

🔗 Linked Issue

Closes #1270

🏷️ PR Type

  • type:chore — Test-only conformance

📝 Summary

  • Verify two interleaved Claude host IDs in the same worktree persist four distinct observations through the production claude-pre-tool-use transformer and real MCP/SQLite handler.
  • Confirm each host owns its exact titles once and no model-supplied foreign session is created. No production behavior change.
  • Independent main-based feat(sessions): add authoritative bindings for concurrent agents #1270 test slice (+99 lines), draft until the umbrella issue is complete; no early merge with Closes #1270.

📂 Changes

File Change
cmd/engram/hook_claude_test.go Isolated hook-to-MCP/SQLite interleaved host persistence test.

🧪 Test Plan

  • Focused go test ./cmd/engram -run '^TestClaudeAdapterPersistsWritesForDistinctSameWorktreeHosts$' -count=1 — passed.
  • Affected go test ./cmd/engram -count=1 — passed.
  • golangci-lint run --new-from-rev=origin/main ./cmd/engram/... — 0 issues; git diff --check — passed. No meaningful RED: this adds existing-compatible conformance coverage.
  • GitHub CI Unit/E2E/Plugin/Lint/platform — pending actual execution.

🤖 Automated Checks

Pending actual GitHub results.

✅ Contributor Checklist

💬 Notes for Reviewers

Ported the exact previously reviewed 3e620141 test function into the current main-based file as f0a30c1b with necessary imports; new native review review-05946c376f94f63d approved/acknowledged. Sessions are seeded; the test manually dispatches MCP, so it does not exercise a real Claude dispatcher, failed/ended registration or skipped-hook behavior. The source guard is a separate draft #1478; this test passes against main without it. No merge requested.

Summary by CodeRabbit

  • Tests
    • Improved coverage for saving observations from separate host sessions working in the same project, including checks that each session’s observations remain correctly associated and that supplied session identifiers do not create extra sessions.

@dnlrsls dnlrsls added the type:chore Maintenance/tooling label Sep 27, 2026
@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 90830397-91f0-4857-859e-27888c410df1

📥 Commits

Reviewing files that changed from the base of the PR and between 22dc220 and c14cf1e.

📒 Files selected for processing (1)
  • cmd/engram/hook_claude_test.go

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Adds an integration test for Claude hook writes from two host sessions in the same worktree. The test checks host attribution, persisted observations, and whether a model-supplied session ID creates a session.

Changes

Claude hook attribution

Layer / File(s) Summary
Verify concurrent host attribution
cmd/engram/hook_claude_test.go
Adds an integration test that alternates writes between two host sessions in a shared worktree. It checks that each host receives its expected observations and that the model-supplied session ID does not create a session.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Suggested reviewers: gentleman-programming

Merge Risk: ⚪ Minimal · up to c14cf

The added test covers interleaved writes from two host sessions without changing runtime behavior. No merge-blocking issue is identified.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning Issue #1270 requires an authoritative runtime-session binding contract and implementation. This PR adds only TestClaudeAdapterPersistsWritesForDistinctSameWorktreeHosts. The test covers concurrent p… Implement the authoritative binding contract required by #1270. Add production coverage for registration, validation, lifecycle, stable attribution, rejection cases, and lease behavior. Add transport-level conformance tests for the required…
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the added test for separate persistence of interleaved Claude host writes.
Out of Scope Changes check ✅ Passed The added test directly supports issue #1270 acceptance criterion 1. It verifies that two concurrent host IDs in one worktree persist records under the correct host and that a model-supplied foreign s…
Full details: Linked Issues check

Explanation

Issue #1270 requires an authoritative runtime-session binding contract and implementation. This PR adds only TestClaudeAdapterPersistsWritesForDistinctSameWorktreeHosts. The test covers concurrent persistence for two interleaved Claude host IDs in one worktree. It does not implement or verify binding stability across compaction and resume, model changes, missing-binding fail-closed behavior, lease expiry, model-independent attribution, or transport-level conformance.

Resolution

Implement the authoritative binding contract required by #1270. Add production coverage for registration, validation, lifecycle, stable attribution, rejection cases, and lease behavior. Add transport-level conformance tests for the required scenarios.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…aude-evidence

# Conflicts:
#	cmd/engram/hook_claude_test.go
@dnlrsls
dnlrsls marked this pull request as ready for review September 28, 2026 21:32
@dnlrsls

dnlrsls commented Sep 28, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@dnlrsls
dnlrsls added this pull request to the merge queue Sep 28, 2026
Merged via the queue into Gentleman-Programming:main with commit 3db907f Sep 28, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:chore Maintenance/tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(sessions): add authoritative bindings for concurrent agents

1 participant