feat(resource): implement ResourceHandler content_hash method #837

Closed
opened 2026-03-13 20:16:42 +00:00 by freemo · 0 comments
Owner

Metadata

  • Commit Message: feat(resource): implement ResourceHandler content_hash method
  • Branch: feature/resource-handler-content-hash
  • Type: Feature
  • Priority: Medium
  • MoSCoW: Should have
  • Points: 3
  • Milestone: v3.6.0

Background and Context

The ResourceHandler protocol defines a content_hash(resource) -> str method that computes a deterministic hash of a resource's content. This hash is used for:

  • Change detection: Comparing hashes to detect if a resource has changed between plan phases
  • Deduplication: The ACMS Phase 2 ContentHashDeduplicator uses content hashes to remove duplicate fragments
  • Virtual resource equivalence: Virtual resources use content hashes to determine equivalence with physical resources
  • Caching: Content-addressed caching of resource states

Currently, no handler implements content_hash(). The ACMS deduplicator cannot function without it.

Acceptance Criteria

  • content_hash() implemented for git-checkout (git hash-object), fs-directory (recursive content hash), devcontainer (exec hash), database (query result hash)
  • Hash is deterministic: same content always produces same hash
  • Hash is content-only: metadata changes (timestamps, permissions) do not affect hash
  • Hash algorithm is configurable (default: SHA-256)
  • Empty/missing resources return a sentinel hash value

Definition of Done

This issue is complete when:

  • All subtasks below are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.

Subtasks

  • Implement content_hash() for git-checkout handler (git hash-object)
  • Implement content_hash() for fs-directory handler (recursive SHA-256)
  • Implement content_hash() for devcontainer handler (exec hash)
  • Implement content_hash() for database handler (query result hash)
  • Add configurable hash algorithm support
  • Add sentinel hash for empty/missing resources
  • Tests (Behave): Add scenarios for hash determinism and change detection
  • Tests (Robot): Add integration test for content hash stability
  • Verify coverage >=97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors
## Metadata - **Commit Message**: `feat(resource): implement ResourceHandler content_hash method` - **Branch**: `feature/resource-handler-content-hash` - **Type**: Feature - **Priority**: Medium - **MoSCoW**: Should have - **Points**: 3 - **Milestone**: v3.6.0 ## Background and Context The ResourceHandler protocol defines a `content_hash(resource) -> str` method that computes a deterministic hash of a resource's content. This hash is used for: - **Change detection**: Comparing hashes to detect if a resource has changed between plan phases - **Deduplication**: The ACMS Phase 2 ContentHashDeduplicator uses content hashes to remove duplicate fragments - **Virtual resource equivalence**: Virtual resources use content hashes to determine equivalence with physical resources - **Caching**: Content-addressed caching of resource states Currently, no handler implements `content_hash()`. The ACMS deduplicator cannot function without it. ## Acceptance Criteria - [x] `content_hash()` implemented for git-checkout (git hash-object), fs-directory (recursive content hash), devcontainer (exec hash), database (query result hash) - [x] Hash is deterministic: same content always produces same hash - [x] Hash is content-only: metadata changes (timestamps, permissions) do not affect hash - [x] Hash algorithm is configurable (default: SHA-256) - [x] Empty/missing resources return a sentinel hash value ## Definition of Done This issue is complete when: - All subtasks below are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. ## Subtasks - [x] Implement `content_hash()` for git-checkout handler (git hash-object) - [x] Implement `content_hash()` for fs-directory handler (recursive SHA-256) - [x] Implement `content_hash()` for devcontainer handler (exec hash) - [x] Implement `content_hash()` for database handler (query result hash) - [x] Add configurable hash algorithm support - [x] Add sentinel hash for empty/missing resources - [x] Tests (Behave): Add scenarios for hash determinism and change detection - [x] Tests (Robot): Add integration test for content hash stability - [x] Verify coverage >=97% via `nox -s coverage_report` - [x] Run `nox` (all default sessions), fix any errors
freemo added this to the v3.6.0 milestone 2026-03-13 20:20:06 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Blocks
Reference
cleveragents/cleveragents-core#837
No description provided.