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
141 changes: 141 additions & 0 deletions .agents/skills/object-storage-lifecycle/SKILL.md

Large diffs are not rendered by default.

72 changes: 72 additions & 0 deletions .agents/skills/object-storage-lifecycle/check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/sh
# Checks the object storage model with TLC. Each config has an expected result: "pass", or the
# rules that break on a known finding. Exit 0 when every config gives its expected result.
# Pass config names (such as LateCommit) to check only those.
set -eu
cd "$(dirname "$0")/model"
mise trust --quiet . >/dev/null
mise install --quiet >/dev/null
jar="$(mise where http:tla2tools)/tla2tools.jar"
java="$(mise which java)"
out=$(mktemp -d)

expected() {
case $1 in
ObjectStorage | Liveness | Chart) echo "pass" ;;
LateCommit | GraceNone | GraceLimit) echo "NoLiveRowWithoutObject" ;;
SoftDeletedNames) echo "liveness" ;;
DeletedTenantOrphan) echo "NoObjectLeftInDeletedTenant" ;;
*) echo "unknown config $1" >&2; exit 2 ;;
esac
}

# The rules that one TLC run breaks. TLC stops at the first broken rule.
broken() {
log=$1
sed -n 's/^Error: Invariant \([A-Za-z0-9_]*\) is violated.*/\1/p' "$log"
grep -q '^Error: Temporal properties were violated' "$log" && echo "liveness"
grep -q '^Error: Deadlock reached' "$log" && echo "NoDeadlock"
true
}

# Runs TLC until no rule breaks, and drops each invariant that breaks from the config of the next run.
result() {
cfg=$1 dir=$2
cp "$cfg.cfg" "$dir/run.cfg"
found=""
run=0
while :; do
run=$((run + 1))
log="$dir/run-$run.out"
"$java" -XX:+UseParallelGC -cp "$jar" tlc2.TLC -workers auto -metadir "$dir/states-$run" \
-config "$dir/run.cfg" ObjectStorage.tla >"$log" 2>&1 || echo "TLC exit code $?" >>"$log"
sed -n 's/.* \([0-9,]*\) distinct states found.*/\1/p' "$log" | tail -1 >"$dir/states"
new=$(broken "$log")
if [ -z "$new" ]; then
grep -q '^Model checking completed. No error has been found' "$log" || found="$found error"
break
fi
found="$found $new"
case $new in liveness | NoDeadlock) break ;; esac
sed -i.bak "s/^\(INVARIANTS* .*\) $new\( .*\)*$/\1\2/" "$dir/run.cfg"
[ $run -lt 6 ] || { found="$found error"; break; }
done
set -- $found
[ $# -gt 0 ] && echo "$@" | tr ' ' '\n' | sort -u | tr '\n' ' ' | sed 's/ $//' || echo "pass"
}

configs=${*:-"ObjectStorage Liveness Chart LateCommit GraceNone GraceLimit SoftDeletedNames DeletedTenantOrphan"}
status=0
for cfg in $configs; do
want=$(expected "$cfg")
mkdir -p "$out/$cfg"
got=$(result "$cfg" "$out/$cfg")
states=$(cat "$out/$cfg/states")
if [ "$got" = "$want" ]; then
echo "baseline $cfg: $got ($states states)"
else
echo "CHANGED $cfg: expected [$want], got [$got] ($states states). TLC output: $out/$cfg"
status=1
fi
done
exit $status
14 changes: 14 additions & 0 deletions .agents/skills/object-storage-lifecycle/model/Chart.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
\* A config small enough for the /statechart chart: one upload, one worker, one attempt, no crash.
\* Expected: no error.
CONSTANTS
Atts = {a1}
Runners = {r1}
MaxAttempts = 1
MaxCrashes = 0
Cleanup = FALSE
CleanupFails = FALSE
LateCommit = FALSE
Grace = "add"
SoftDeletedNames = FALSE
SPECIFICATION Spec
INVARIANTS TypeOK NoLiveRowWithoutObject NoLiveRowInDeletedTenant
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
\* The worst case of F1: a put lands under a deleted tenant after its DeleteTenantObjects job listed
\* the prefix. The witness NoObjectLeftInDeletedTenant breaks, so TLC shows the path. On the same scope, OrphansGo
\* holds: the sweep deletes the object. Expected: NoObjectLeftInDeletedTenant breaks, and nothing else.
CONSTANTS
Atts = {a1}
Runners = {r1}
MaxAttempts = 1
MaxCrashes = 1
Cleanup = FALSE
CleanupFails = FALSE
LateCommit = FALSE
Grace = "add"
SoftDeletedNames = FALSE
SPECIFICATION Spec
INVARIANTS TypeOK NoObjectLeftInDeletedTenant
PROPERTIES OrphansGo
14 changes: 14 additions & 0 deletions .agents/skills/object-storage-lifecycle/model/GraceLimit.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
\* A grace of only the time limit, with no margin for a COMMIT that ends after its cancel.
\* Expected: NoLiveRowWithoutObject breaks.
CONSTANTS
Atts = {a1}
Runners = {r1}
MaxAttempts = 1
MaxCrashes = 0
Cleanup = FALSE
CleanupFails = FALSE
LateCommit = TRUE
Grace = "limit"
SoftDeletedNames = FALSE
SPECIFICATION Spec
INVARIANTS TypeOK NoLiveRowWithoutObject NoLiveRowInDeletedTenant
14 changes: 14 additions & 0 deletions .agents/skills/object-storage-lifecycle/model/GraceNone.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
\* A grace shorter than the time limit of an add. The sweep deletes the object of an add that still
\* saves its row. Expected: NoLiveRowWithoutObject breaks.
CONSTANTS
Atts = {a1}
Runners = {r1}
MaxAttempts = 1
MaxCrashes = 0
Cleanup = FALSE
CleanupFails = FALSE
LateCommit = FALSE
Grace = "none"
SoftDeletedNames = FALSE
SPECIFICATION Spec
INVARIANTS TypeOK NoLiveRowWithoutObject NoLiveRowInDeletedTenant
14 changes: 14 additions & 0 deletions .agents/skills/object-storage-lifecycle/model/LateCommit.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
\* Finding F2, with the cleanup at once of the code before the sweep. A save throws while its COMMIT is
\* still in flight, and the cleanup deletes the object. Expected: NoLiveRowWithoutObject breaks.
CONSTANTS
Atts = {a1}
Runners = {r1}
MaxAttempts = 1
MaxCrashes = 0
Cleanup = TRUE
CleanupFails = FALSE
LateCommit = TRUE
Grace = "add"
SoftDeletedNames = FALSE
SPECIFICATION Spec
INVARIANTS TypeOK NoLiveRowWithoutObject NoLiveRowInDeletedTenant
15 changes: 15 additions & 0 deletions .agents/skills/object-storage-lifecycle/model/Liveness.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
\* The liveness gate: each job, add, COMMIT, and tenant delete ends, and the sweep deletes each object that no
\* live row names. Smaller than the safety gate, because TLC checks liveness on the whole graph. Expected: no error.
CONSTANTS
Atts = {a1}
Runners = {r1, r2}
MaxAttempts = 2
MaxCrashes = 1
Cleanup = FALSE
CleanupFails = FALSE
LateCommit = TRUE
Grace = "add"
SoftDeletedNames = FALSE
SPECIFICATION Spec
INVARIANT TypeOK
PROPERTIES RequestsSettle AddsSettle CommitsSettle TenantDeleteSettles OrphansGo
14 changes: 14 additions & 0 deletions .agents/skills/object-storage-lifecycle/model/ObjectStorage.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
\* The safety gate. Every fault that the code must survive is on, with the code of now: no cleanup at once,
\* and a sweep whose grace covers the time limit of an add and a COMMIT in flight. Expected: no error.
CONSTANTS
Atts = {a1, a2}
Runners = {r1, r2}
MaxAttempts = 1
MaxCrashes = 1
Cleanup = FALSE
CleanupFails = FALSE
LateCommit = TRUE
Grace = "add"
SoftDeletedNames = FALSE
SPECIFICATION Spec
INVARIANTS TypeOK NoLiveRowWithoutObject NoLiveRowInDeletedTenant
Loading
Loading