Skip to content

Guarded Change Reevaluation

A memory can guard a function with guards on_change require ReEvaluation<Self>. Once that guard exists, modifying or removing the function requires a matching reevaluation.

This model fails because it modifies Gateway.derivePolicyDecision without reevaluating the recorded refactor constraint:

module gateway
resource PolicySnapshot
component Gateway {
owns PolicySnapshot
grants Read<PolicySnapshot>
fn derivePolicyDecision : RefactorSensitive
effects complete {
Read<PolicySnapshot>
}
}
memory DecisionRefactorConstraint : RefactorConstraint<fn Gateway.derivePolicyDecision> {
applies_to fn Gateway.derivePolicyDecision
status Unexplained
confidence High
summary "Previous refactors broke error normalisation."
who { owner GatewayTeam }
guards { on_change require ReEvaluation<Self> }
}
change RefactorDecision {
modify fn Gateway.derivePolicyDecision
effects complete {
Read<PolicySnapshot>
}
}

Run:

Terminal window
shp check fixtures/fail/memory_guard_modify_without_reevaluation/audit.shape

The relevant diagnostic is:

error: guarded shape changed
fn Gateway.derivePolicyDecision is protected by memory DecisionRefactorConstraint.
This change modifies the guarded target.
Required:
add reevaluation satisfying memory DecisionRefactorConstraint
or preserve the protected shape.

Adding a valid reevaluation makes the guarded change explicit:

module gateway
resource PolicySnapshot
component Gateway {
owns PolicySnapshot
grants Read<PolicySnapshot>
fn derivePolicyDecision : RefactorSensitive
effects complete {
Read<PolicySnapshot>
}
}
memory DecisionRefactorConstraint : RefactorConstraint<fn Gateway.derivePolicyDecision> {
applies_to fn Gateway.derivePolicyDecision
status Unexplained
confidence High
summary "Previous refactors broke error normalisation."
who { owner GatewayTeam }
guards { on_change require ReEvaluation<Self> }
}
reevaluation DecisionShapeRechecked {
satisfies memory DecisionRefactorConstraint
outcome Confirmed
summary "Refactor preserves error-normalisation behaviour."
reviewer GatewayTeam
decided_on "2026-06-02"
evidence test("gateway/error-normalisation.test.ts")
}
change RefactorDecision {
modify fn Gateway.derivePolicyDecision
effects complete {
Read<PolicySnapshot>
}
}

Run:

Terminal window
shp check fixtures/pass/memory_guard_modify_with_reevaluation/audit.shape

The model passes because the change includes review evidence for the protected target.