UAT: DecisionService._auto_capture_snapshot does not capture resource references or actor_state_ref as required by spec #3125

Open
opened 2026-04-05 06:36:48 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: bugfix/m3-decision-auto-capture-snapshot-full-context
  • Commit Message: fix(decision): capture resource references and actor_state_ref in auto snapshot
  • Milestone: None (backlog — see note below)
  • Parent Epic: #357

Backlog note: This issue was discovered during autonomous operation
on milestone v3.2.0. It does not block milestone completion and has been
placed in the backlog for human review and future milestone assignment.

Bug Report

Feature Area: Decision Recording — Context Snapshot Auto-capture (v3.2.0)

What was tested

Code analysis of src/cleveragents/application/services/decision_service.py:

  • Lines 959–989: _auto_capture_snapshot static method
  • Lines 363–368: call site in record_decision

Spec Reference

docs/specification.md line 18647 (Decision Recording Protocol — context snapshot auto-capture):

"The system automatically captures the context snapshot at the moment of the call — the hot context hash, resource references, and a LangGraph checkpoint of the actor's complete state (actor_state_ref). This snapshot enables replay from the exact decision point during correction."

Expected Behavior

When record_decision is called without an explicit context_snapshot, the system should automatically capture:

  • A cryptographic hash of the hot context window
  • A storage reference to the full serialized context
  • The list of relevant resource references (relevant_resources)
  • The LangGraph actor checkpoint reference (actor_state_ref)

Actual Behavior

_auto_capture_snapshot() only generates a minimal SHA-256 hash from question + chosen_option:

# Lines 959–989 — current implementation
hot_context_hash = sha256(question + chosen_option)[:16]
# relevant_resources is always []
# actor_state_ref is always ""

Specifically:

  • hot_context_hash is derived only from question + chosen_option, not from the actual hot context window
  • relevant_resources is always an empty list in auto-captured snapshots
  • actor_state_ref is always an empty string in auto-captured snapshots
  • The method is explicitly described in the code as "minimal" and is only used as a fallback when no explicit snapshot is provided

This means decisions recorded without explicit snapshots cannot be replayed from their exact decision point, which breaks the correction feature (plan correct --mode=revert).

Code Locations

  • src/cleveragents/application/services/decision_service.py lines 959–989 (_auto_capture_snapshot)
  • src/cleveragents/application/services/decision_service.py lines 363–368 (call site in record_decision)

Notes on Fix Approach

This may require integration with the LangGraph actor framework (ADR-033) to properly capture actor state. Two viable approaches:

  1. Actor-provided snapshot: The actor calling record_decision provides an explicit snapshot from its current LangGraph state, rather than relying on auto-capture. The record_decision tool implementation would be responsible for constructing the snapshot from the actor's current state before calling the service.
  2. Enhanced auto-capture: _auto_capture_snapshot is enhanced to accept the actor's current context and state as parameters, enabling it to generate a full snapshot rather than a minimal hash.

Subtasks

  • Investigate LangGraph actor state access patterns (ADR-033) to determine how actor_state_ref checkpoints can be captured at decision time
  • Determine whether the fix should be in _auto_capture_snapshot (enhanced auto-capture) or in the record_decision tool implementation (actor-provided snapshot)
  • Implement the chosen approach so that relevant_resources and actor_state_ref are populated in all auto-captured snapshots
  • Ensure hot_context_hash reflects the actual hot context window, not just question + chosen_option
  • Add/update unit tests for _auto_capture_snapshot to assert all four snapshot fields are populated
  • Add BDD scenario: decision recorded without explicit snapshot can be replayed via plan correct --mode=revert
  • Verify plan correct --mode=revert correctly uses the captured actor_state_ref to restore actor state at the decision point
  • Run nox (all default sessions), fix any errors
  • Verify coverage >= 97% via nox -s coverage_report

Definition of Done

  • _auto_capture_snapshot (or the record_decision tool) populates relevant_resources with the resource references that influenced the decision
  • _auto_capture_snapshot (or the record_decision tool) populates actor_state_ref with a valid LangGraph checkpoint reference
  • hot_context_hash reflects the actual hot context window at decision time, not a hash of question + chosen_option
  • Decisions recorded without an explicit context_snapshot can be replayed from their exact decision point via plan correct --mode=revert
  • Unit tests for _auto_capture_snapshot assert all four snapshot fields are non-empty for a normal decision recording call
  • BDD scenario covering auto-captured snapshot replay passes
  • All nox stages pass
  • Coverage >= 97%

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-new-issue-creator

## Metadata - **Branch**: `bugfix/m3-decision-auto-capture-snapshot-full-context` - **Commit Message**: `fix(decision): capture resource references and actor_state_ref in auto snapshot` - **Milestone**: None (backlog — see note below) - **Parent Epic**: #357 > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.2.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. ## Bug Report **Feature Area**: Decision Recording — Context Snapshot Auto-capture (v3.2.0) ### What was tested Code analysis of `src/cleveragents/application/services/decision_service.py`: - Lines 959–989: `_auto_capture_snapshot` static method - Lines 363–368: call site in `record_decision` ### Spec Reference `docs/specification.md` line 18647 (Decision Recording Protocol — context snapshot auto-capture): > "The system automatically captures the **context snapshot** at the moment of the call — the hot context hash, resource references, and a LangGraph checkpoint of the actor's complete state (`actor_state_ref`). This snapshot enables replay from the exact decision point during correction." ### Expected Behavior When `record_decision` is called without an explicit `context_snapshot`, the system should automatically capture: - A cryptographic hash of the hot context window - A storage reference to the full serialized context - The list of relevant resource references (`relevant_resources`) - The LangGraph actor checkpoint reference (`actor_state_ref`) ### Actual Behavior `_auto_capture_snapshot()` only generates a minimal SHA-256 hash from `question + chosen_option`: ```python # Lines 959–989 — current implementation hot_context_hash = sha256(question + chosen_option)[:16] # relevant_resources is always [] # actor_state_ref is always "" ``` Specifically: - `hot_context_hash` is derived only from `question + chosen_option`, not from the actual hot context window - `relevant_resources` is always an empty list in auto-captured snapshots - `actor_state_ref` is always an empty string in auto-captured snapshots - The method is explicitly described in the code as "minimal" and is only used as a fallback when no explicit snapshot is provided This means decisions recorded without explicit snapshots **cannot be replayed from their exact decision point**, which breaks the correction feature (`plan correct --mode=revert`). ### Code Locations - `src/cleveragents/application/services/decision_service.py` lines 959–989 (`_auto_capture_snapshot`) - `src/cleveragents/application/services/decision_service.py` lines 363–368 (call site in `record_decision`) ### Notes on Fix Approach This may require integration with the LangGraph actor framework (ADR-033) to properly capture actor state. Two viable approaches: 1. **Actor-provided snapshot**: The actor calling `record_decision` provides an explicit snapshot from its current LangGraph state, rather than relying on auto-capture. The `record_decision` tool implementation would be responsible for constructing the snapshot from the actor's current state before calling the service. 2. **Enhanced auto-capture**: `_auto_capture_snapshot` is enhanced to accept the actor's current context and state as parameters, enabling it to generate a full snapshot rather than a minimal hash. ## Subtasks - [ ] Investigate LangGraph actor state access patterns (ADR-033) to determine how `actor_state_ref` checkpoints can be captured at decision time - [ ] Determine whether the fix should be in `_auto_capture_snapshot` (enhanced auto-capture) or in the `record_decision` tool implementation (actor-provided snapshot) - [ ] Implement the chosen approach so that `relevant_resources` and `actor_state_ref` are populated in all auto-captured snapshots - [ ] Ensure `hot_context_hash` reflects the actual hot context window, not just `question + chosen_option` - [ ] Add/update unit tests for `_auto_capture_snapshot` to assert all four snapshot fields are populated - [ ] Add BDD scenario: decision recorded without explicit snapshot can be replayed via `plan correct --mode=revert` - [ ] Verify `plan correct --mode=revert` correctly uses the captured `actor_state_ref` to restore actor state at the decision point - [ ] Run `nox` (all default sessions), fix any errors - [ ] Verify coverage >= 97% via `nox -s coverage_report` ## Definition of Done - [ ] `_auto_capture_snapshot` (or the `record_decision` tool) populates `relevant_resources` with the resource references that influenced the decision - [ ] `_auto_capture_snapshot` (or the `record_decision` tool) populates `actor_state_ref` with a valid LangGraph checkpoint reference - [ ] `hot_context_hash` reflects the actual hot context window at decision time, not a hash of `question + chosen_option` - [ ] Decisions recorded without an explicit `context_snapshot` can be replayed from their exact decision point via `plan correct --mode=revert` - [ ] Unit tests for `_auto_capture_snapshot` assert all four snapshot fields are non-empty for a normal decision recording call - [ ] BDD scenario covering auto-captured snapshot replay passes - All nox stages pass - Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
freemo added this to the v3.2.0 milestone 2026-04-05 06:42:55 +00:00
freemo removed this from the v3.2.0 milestone 2026-04-06 20:51:14 +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#3125
No description provided.