fix(autonomy-guardrail): make load_from_metadata atomic #8215

Merged
HAL9000 merged 3 commits from fix/7504-atomic-guardrail-load into master 2026-04-23 09:22:24 +00:00

3 Commits

Author SHA1 Message Date
HAL9000 fe5989b686 fix(autonomy-guardrail): add CHANGELOG entry and resolve merge conflicts
CI / push-validation (pull_request) Successful in 29s
CI / helm (pull_request) Successful in 32s
CI / build (pull_request) Successful in 1m0s
CI / lint (pull_request) Successful in 1m11s
CI / typecheck (pull_request) Successful in 1m37s
CI / quality (pull_request) Successful in 1m55s
CI / security (pull_request) Successful in 1m58s
CI / benchmark-publish (pull_request) Has been skipped
CI / e2e_tests (pull_request) Successful in 4m29s
CI / unit_tests (pull_request) Successful in 4m34s
CI / integration_tests (pull_request) Successful in 8m9s
CI / docker (pull_request) Successful in 1m53s
CI / coverage (pull_request) Successful in 11m53s
CI / benchmark-regression (push) Waiting to run
CI / benchmark-publish (push) Waiting to run
CI / status-check (pull_request) Successful in 5s
CI / lint (push) Successful in 59s
CI / helm (push) Successful in 34s
CI / build (push) Successful in 52s
CI / push-validation (push) Successful in 32s
CI / typecheck (push) Successful in 1m34s
CI / quality (push) Successful in 1m34s
CI / security (push) Successful in 1m47s
CI / e2e_tests (push) Successful in 4m25s
CI / unit_tests (push) Successful in 4m48s
CI / integration_tests (push) Successful in 6m11s
CI / docker (push) Successful in 1m45s
CI / coverage (push) Successful in 11m48s
CI / status-check (push) Waiting to run
CI / benchmark-regression (pull_request) Successful in 1h4m10s
Added CHANGELOG.md entry under [Unreleased] > Fixed for issue #7504
documenting the atomic load_from_metadata fix. Resolved merge conflict
in pyproject.toml by combining both B010 and I001 ruff ignore rules
for Behave step files. Rebased on latest master to resolve mergeable
status.

ISSUES CLOSED: #7504
2026-04-23 09:08:11 +00:00
HAL9000 47b37c43f0 fix(autonomy-guardrail): fix BDD test assertions and error handling
- Replace no-op assertions in step_assert_in_sync and step_assert_both_in_sync with meaningful state validation checks
- Set context.error in addition to context.load_error so generic validation error steps work correctly
- Add missing step definition for "I have metadata with valid guardrails"
- Store plan_id in context during load steps for use in assertion steps

All atomic load BDD tests now pass with proper validation of guardrail and audit trail state.
2026-04-23 09:08:11 +00:00
HAL9000 ef532c5302 fix(autonomy-guardrail): make load_from_metadata atomic
Refactor load_from_metadata() to validate both AutonomyGuardrails and
GuardrailAuditTrail models before writing either to state. This ensures
atomicity: if any validation fails, no state is modified.

Previously, guardrails were written before audit trail validation,
leaving the system in an inconsistent state if the second validation
failed.

Changes:
- Validate both models in Phase 1 before any writes
- Write both models atomically in Phase 2 only after validation succeeds
- Add comprehensive BDD tests for atomic load behavior
- Update pyproject.toml to ignore import sorting in features/steps

ISSUES CLOSED: #7504
2026-04-23 09:08:11 +00:00