Files
cleveragents-core/features/steps/checkpoint_manager_bug7488_steps.py
HAL9000 66850665b7
CI / push-validation (pull_request) Successful in 10s
CI / helm (pull_request) Successful in 33s
CI / lint (pull_request) Successful in 44s
CI / quality (pull_request) Successful in 48s
CI / security (pull_request) Successful in 54s
CI / e2e_tests (pull_request) Successful in 3m14s
CI / build (pull_request) Successful in 3m25s
CI / typecheck (pull_request) Successful in 4m1s
CI / integration_tests (pull_request) Successful in 6m33s
CI / unit_tests (pull_request) Successful in 7m48s
CI / docker (pull_request) Successful in 55s
CI / coverage (pull_request) Successful in 5m58s
CI / status-check (pull_request) Successful in 2s
CI / benchmark-regression (push) Failing after 0s
CI / benchmark-publish (push) Failing after 0s
CI / push-validation (push) Successful in 13s
CI / lint (push) Successful in 19s
CI / helm (push) Successful in 24s
CI / build (push) Successful in 31s
CI / quality (push) Successful in 39s
CI / typecheck (push) Successful in 42s
CI / security (push) Successful in 43s
CI / e2e_tests (push) Successful in 3m20s
CI / unit_tests (push) Successful in 3m36s
CI / integration_tests (push) Successful in 4m34s
CI / docker (push) Successful in 1m38s
CI / coverage (push) Successful in 9m25s
CI / status-check (push) Successful in 1s
fix(sandbox): split oversized step file and update CONTRIBUTORS.md
Split checkpoint_manager_coverage_steps.py (692 lines) into three
focused modules to comply with the 500-line file limit:

- checkpoint_manager_coverage_steps.py: model, protocol, manager init,
  create_checkpoint, _snapshot_directory, and _cleanup_snapshot steps
  (408 lines)
- checkpoint_manager_rollback_steps.py: rollback_to, list_checkpoints,
  and delete_checkpoint branch steps (283 lines)
- checkpoint_manager_bug7488_steps.py: Bug #7488 sandbox_path
  auto-stored-in-metadata steps (59 lines)

Also updated CONTRIBUTORS.md to document HAL 9000's contribution for
bug fix #7488 as required by CONTRIBUTING.md guidelines.

ISSUES CLOSED: #7488
2026-04-17 18:34:16 +00:00

60 lines
2.3 KiB
Python

"""Step definitions for Bug #7488 — sandbox_path auto-stored in checkpoint metadata.
These steps verify that create_checkpoint() automatically stores sandbox_path
in metadata from sandbox.context.sandbox_path, enabling rollback_to() to work
without the caller manually supplying sandbox_path in metadata.
Split from checkpoint_manager_coverage_steps.py to keep files under 500 lines.
"""
from __future__ import annotations
import os
from behave import given, then
from behave.runner import Context
def _register_cleanup(context: Context, path: str) -> None:
"""Schedule a directory for cleanup after the scenario."""
if not hasattr(context, "_cleanup_handlers"):
context._cleanup_handlers = []
context._cleanup_handlers.append(
lambda p=path: __import__("shutil").rmtree(p, ignore_errors=True)
)
@then("the returned checkpoint metadata should contain the sandbox path")
def step_assert_metadata_has_sandbox_path(context: Context) -> None:
"""Verify that create_checkpoint() automatically stores sandbox_path in metadata."""
cp = context.cp_result
_register_cleanup(context, os.path.dirname(cp.snapshot_path))
assert "sandbox_path" in cp.metadata, (
"Expected 'sandbox_path' key in checkpoint metadata, but it was not found. "
"Bug #7488: create_checkpoint() must store sandbox_path in metadata."
)
assert cp.metadata["sandbox_path"] == context.temp_sandbox, (
f"Expected sandbox_path={context.temp_sandbox!r}, "
f"got {cp.metadata['sandbox_path']!r}"
)
@given(
"a checkpoint was created for the temporary sandbox without explicit sandbox_path metadata"
)
def step_create_cp_for_temp_sandbox_no_explicit_path(context: Context) -> None:
"""Create a checkpoint without manually supplying sandbox_path in metadata.
After the fix for bug #7488, create_checkpoint() should automatically
store sandbox_path in metadata from sandbox.context.sandbox_path.
"""
context.cp_result = context.mgr.create_checkpoint(
sandbox=context.mock_sb,
plan_id="plan-rb-autopath",
phase="pre_execute",
# Intentionally NOT passing sandbox_path in metadata — the fix should
# auto-populate it from sandbox.context.sandbox_path.
)
_register_cleanup(context, os.path.dirname(context.cp_result.snapshot_path))
context.crafted_cp = context.cp_result