Action Precondition Checker
Compare a proposed write with current state and exact approval references before execution.
Version: 1.0.0. License: MIT. Status: tested reference baseline; no comparative ranking is claimed.
Contract
For each action, compare expected state with the caller-supplied observed value for its resource. Require a listed nonempty authorization reference. Return ready only if both checks pass. Unknown resources fail the state check; no action is executed. Comparison uses the Python JSON profile described in the implementation, including number representation.
The exact required input fields and types are in input.schema.json. Extra fields are rejected at declared object boundaries. JSON duplicate keys and non-finite numbers are rejected by the CLI. Input strings are case-sensitive unless stated otherwise. Array order is preserved unless the contract specifies sorting.
Use
Unpack the ZIP, enter its directory, and run:
python3 baseline.py < example.input.json
python3 -m unittest -v
Python 3.10 or newer, standard library only. The reference implementation exposes run(input_dict) and accepts one JSON object on standard input. Success returns {"ok": true, "result": ...} with exit code 0. Invalid input returns {"ok": false, "error": "..."} with exit code 1. example.output.json contains the result without the CLI envelope. Import callers receive exceptions for invalid input.
Example input
{
"actions": [
{
"id": "a",
"resource": "doc:1",
"expected": {
"revision": 2
},
"proposed": {
"title": "Updated"
},
"authorization_ref": "approval:1"
}
],
"observed": {
"doc:1": {
"revision": 2
}
},
"authorizations": [
"approval:1"
]
}
Example result
{
"ready": true,
"actions": [
{
"id": "a",
"state_matches": true,
"authorization_listed": true,
"ready": true
}
]
}
Boundaries
The observed object accepts arbitrary resource names. Authorization references are caller assertions, not authenticated grants. This preview does not prevent a race; a real write must atomically enforce its expected state or revision. A matching plan is not permission by itself.
This package performs no network calls, executes no submitted commands, and writes no user files. Host applications own authorization, resource budgets, and persistence. Example values are fixtures, not recommended policies or limits.
Acceptance and provenance
cases.json records named expected results and rejection cases. test_baseline.py runs those cases and checks the command-line contract. manifest.json records file digests. The specification, implementation, and evidence are separate files so a replacement implementation can target the same contract.
Original code and examples generated for this Arcomm collection. No third-party code is bundled. Read LICENSE for reuse terms.
Download
SHA-256: 3d98d51b19f452c8d829f41d5777e98d689d3e34e9af613d8ac34c7dd1102072
Size: 6975 bytes.