Skip to content

feat(compliance): PR 2 — restart continuity via SessionID#2

Closed
OpsKern wants to merge 1 commit into
mainfrom
pr/restart-continuity
Closed

feat(compliance): PR 2 — restart continuity via SessionID#2
OpsKern wants to merge 1 commit into
mainfrom
pr/restart-continuity

Conversation

@OpsKern
Copy link
Copy Markdown
Contributor

@OpsKern OpsKern commented May 5, 2026

Summary

  • Adds Config.SessionID written into every ChainEntry and included in the Merkle hash (with omitempty for backwards compatibility with v0.1.0 chains)
  • writ.New() emits a warning via Client.Warnings() when the chain's last entry has a different non-empty session_id, flagging a cross-restart boundary for human review
  • New VerifyFull() (*VerifyResult, error) method returns structured results: Valid, EntryCount, RootHash, and SessionGaps — without breaking the existing Verify(path) package-level API
  • Fixes a latent bug in verifyChain: JSONL round-trip deserialises Timestamp as string, not time.Time; the old type assertion silently produced "", causing hash mismatch for all file-backed store entries

EU AI Act Article 12

Closes the Restart continuity PARTIAL item: chain now records session boundaries, enabling auditors to detect and explain gaps across process restarts.

Test plan

  • TestSessionIDWrittenToChain — session_id propagates and chain verifies
  • TestSessionIDMismatchWarning — warning fires on session_id change
  • TestSessionIDMatchNoWarning — no false-positive warning on same session
  • TestVerifyFullSessionGapDetected — SessionGaps populated for multi-session chain
  • TestVerifyFullNoGapsForSingleSession — no gaps for single-session chain
  • go test -race ./... PASS
  • gosec ./... 0 issues
  • govulncheck ./... clean

🤖 Generated with Claude Code

Add SessionID to Config, ChainEntry, and Merkle hash so process-restart
boundaries are detectable in the audit chain.

- Config.SessionID written into every chain entry
- NewWithContext warns (via Client.Warnings()) when chain's last entry has a
  different non-empty session_id, flagging a cross-restart chain
- VerifyFull() returns VerifyResult with Valid, EntryCount, RootHash, and
  SessionGaps — structured session-boundary detection without breaking
  existing Verify() API
- SessionID uses omitempty in HashContent so pre-v0.2 entries remain
  verifiable (no hash drift on upgrade)
- Fix chainTimestampStr helper: JSONL round-trip deserialises Timestamp as
  string, not time.Time; verifyChain was silently using "" causing hash
  mismatch for file-backed stores

gosec: 0 issues (1 nosec); go test -race: PASS; govulncheck: clean

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@OpsKern OpsKern force-pushed the pr/restart-continuity branch from aaaffd3 to d6a788a Compare May 6, 2026 02:11
@OpsKern
Copy link
Copy Markdown
Contributor Author

OpsKern commented May 6, 2026

Squash-merged directly to main (commit 314efa0) — PR-2 changes fully incorporated alongside PR-1 conflict resolution.

@OpsKern OpsKern closed this May 6, 2026
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