flayer.core.state¶
flayer.core.state ¶
Minimal owned-resource snapshots with strict reads and atomic local persistence.
StateError ¶
Bases: ContractError
Owned state is malformed, mismatched, busy, or cannot be persisted safely.
ResourceState
dataclass
¶
ResourceState(logical_id: str, kind: str, resource_id: str)
StackState
dataclass
¶
StackState(identity: StackIdentity, resources: tuple[ResourceState, ...] = (), schema_version: int = SCHEMA_VERSION)
Immutable resource inventory scoped to a complete ownership identity.
ParseState ¶
ParseState(data: Mapping[str, object], expected_identity: StackIdentity) -> StackState
Decode a versioned snapshot and require explicit caller ownership expectations.
Source code in installed/flayer/core/state.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
LoadState ¶
LoadState(path: str | Path, expected_identity: StackIdentity) -> StackState | None
Return a strictly owned snapshot, or None only when the file is absent.
Source code in installed/flayer/core/state.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
SaveState ¶
SaveState(path: str | Path, state: StackState, expected_identity: StackIdentity) -> None
Atomically save owned state; never replace a foreign or malformed existing snapshot.
Source code in installed/flayer/core/state.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | |
RemoveState ¶
RemoveState(path: str | Path, expected_identity: StackIdentity) -> bool
Remove only a matching local snapshot; never delete infrastructure resources.
Source code in installed/flayer/core/state.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | |