Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/plan-artifacts.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ The NPM live-state fingerprint is scoped to the reviewed plan. It covers all
resources owned by every owner represented in the plan, together with foreign
or unmanaged resources that could collide with a target natural key, proxy
domain, reusable certificate domain set, or explicit certificate/access-list
ID. This permits independent owners to plan and apply concurrently without
ID. Access-list targets use their names as natural keys and contribute an empty
domain list. This permits independent owners to plan and apply concurrently without
weakening optimistic concurrency for the resources that can affect either
plan. A same-owner change or a newly introduced collision still makes the plan
stale and fails closed. Artifacts produced by versions that used the former
Expand Down
2 changes: 1 addition & 1 deletion packages/wyrmctl/src/wyrmctl/artifacts/live_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def _target(resource: Any) -> dict[str, Any]:
return {
"kind": resource.kind.value,
"natural_key": _json_key(resource.natural_key),
"domain_names": sorted(resource.domain_names),
"domain_names": [] if resource.kind == ResourceKind.ACCESS_LIST else sorted(resource.domain_names),
}


Expand Down
29 changes: 29 additions & 0 deletions packages/wyrmctl/tests/unit/test_live_state_fingerprint.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from __future__ import annotations

from wyrmctl.artifacts.live_state import scoped_live_state_fingerprint
from wyrmctl.contracts import semantic_digest
from wyrmctl.models import (
DesiredAccessList,
DesiredCertificate,
DesiredProxyHost,
ExistingResource,
Expand Down Expand Up @@ -137,6 +139,33 @@ def test_explicit_access_list_id_change_invalidates_plan() -> None:
assert scoped_live_state_fingerprint(plan, before) != scoped_live_state_fingerprint(plan, after)


def test_desired_access_list_fingerprint_uses_name_and_empty_domains() -> None:
desired = DesiredAccessList.from_mapping(
{
"name": "private",
"meta": {"managed_by": "wyrmctl", "owner": "owner-a", "resource_id": "acl.private"},
},
path="access_list",
)
plan = Plan((PlanOperation(PlanAction.CREATE, desired.kind, desired=desired),), (), 0)
fingerprint = scoped_live_state_fingerprint(plan, ExistingState())

assert fingerprint == semantic_digest(
{
"scopeVersion": 1,
"owners": ["owner-a"],
"targets": [{"kind": desired.kind.value, "natural_key": "private", "domain_names": []}],
"resources": [],
}
)
assert fingerprint != scoped_live_state_fingerprint(
plan, ExistingState(access_lists=(_access_list(8, owner="owner-b"),))
)
assert fingerprint == scoped_live_state_fingerprint(
plan, ExistingState(access_lists=(_access_list(8, owner="owner-b", name="other"),))
)


def test_fingerprint_is_deterministic_across_live_resource_order() -> None:
plan = _proxy_plan()
first = _proxy(1, ["first.example.net"], owner="owner-a")
Expand Down
Loading