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
9 changes: 1 addition & 8 deletions docs/scanner-usage-validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,7 @@ static/version accounting probes. Metadata-specific probes return
`UNSUPPORTED`; a missing carried/observed sampling window is `BLOCKED`.
The adapter never derives a certificate from `last_update` or collection time.

Every public Admin sample now carries a scanner-cycle observation in the
evidence record. The sample must contain a non-negative `scanner_cycle`; cycle
values may stay equal while a bucket is being polled, but they may never move
backwards. When `scanner_epoch` is exposed, the epoch must remain stable for
the probe. A missing cycle, a malformed epoch, a cycle regression, or an epoch
change is a product failure and cannot be retried into a pass. This binds the
public usage result to a real scanner snapshot without claiming private
frontier or acknowledgement evidence.
Every public Admin sample records its scanner-cycle observation. An explicitly incomplete view with no bucket values, update time or scan identity can be observed while waiting for publication. It carries no cycle, leaves the last observed cycle and epoch intact, and cannot satisfy convergence. Other views must include a non-negative integer `scanner_cycle`, and any supplied `scanner_epoch` must be a non-negative integer. Cycle regression, epoch changes and malformed identities fail immediately. An unpublished view that persists past the existing convergence deadline also fails the probe.

Default request timeout is 30 seconds, convergence timeout 600 seconds, and
poll interval 5 seconds. `--objects` defaults to 32 and is bounded at 100000.
Expand Down
23 changes: 15 additions & 8 deletions scripts/validation_scanner_usage/cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,34 @@ class CycleTracker:

def __init__(self) -> None:
self.last_cycle: dict[int, int] = {}
self.epoch: str | None = None
self.epoch: int | None = None

def observe(self, snapshot: dict[str, Any], endpoint_index: int) -> dict[str, Any]:
cycle = snapshot.get("scanner_cycle")
if not integer(cycle):
raise ProbeError("Admin usage response has no non-negative scanner cycle", "FAIL")
epoch = snapshot.get("scanner_epoch")
if epoch is not None and (not isinstance(epoch, str) or not epoch):
# Before a snapshot covers any current bucket, the Admin endpoint can
# return an empty, explicitly incomplete view without a scan identity.
unpublished = ("scanner_cycle" not in snapshot and epoch is None
and snapshot.get("usage_snapshot_complete") is False
and snapshot.get("last_update") is None
and snapshot.get("buckets_usage") == {})
if not integer(cycle) and not unpublished:
raise ProbeError("Admin usage response has no non-negative scanner cycle", "FAIL")
if epoch is not None and not integer(epoch):
raise ProbeError("Admin usage response has an invalid scanner epoch", "FAIL")
if self.epoch is None:
self.epoch = epoch
elif epoch is not None and epoch != self.epoch:
raise ProbeError("Admin usage response changed scanner epoch during a probe", "FAIL")
previous = self.last_cycle.get(endpoint_index)
if previous is not None and cycle < previous:
raise ProbeError("Admin usage response regressed scanner cycle", "FAIL")
self.last_cycle[endpoint_index] = cycle
if cycle is not None:
if previous is not None and cycle < previous:
raise ProbeError("Admin usage response regressed scanner cycle", "FAIL")
self.last_cycle[endpoint_index] = cycle
return {
"endpoint_index": endpoint_index,
"scanner_cycle": cycle,
"scanner_epoch": epoch,
"previous_cycle": previous,
"advanced": previous is not None and cycle > previous,
"advanced": cycle is not None and previous is not None and cycle > previous,
}
75 changes: 67 additions & 8 deletions test_validation_scanner_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def snapshot(entry=None, **changes):
return value


def unpublished_snapshot():
return {"last_update": None, "usage_snapshot_complete": False, "buckets_usage": {}}


def options(**changes):
value = dict(endpoints=["http://example.invalid:9000"], admin_endpoints=[],
execution="combined", aws_bin="aws", region="us-east-1", request_timeout=1,
Expand Down Expand Up @@ -124,7 +128,7 @@ def arg(name, default=None):
def admin(self, path="/rustfs/admin/v3/datausageinfo", endpoint_index=0):
if self.malformed:
raise ProbeError("Admin returned invalid JSON")
value = {"scanner_cycle": self.serial, "usage_snapshot_complete": True,
value = {"scanner_cycle": self.serial, "scanner_epoch": 1, "usage_snapshot_complete": True,
"usage_snapshot_converged": not self.pending, "buckets_usage": {}}
for bucket, rows in self.buckets.items():
value["buckets_usage"][bucket] = {"objects_count": len({row["Key"] for row in rows}),
Expand All @@ -140,20 +144,42 @@ def admin(self, path="/rustfs/admin/v3/datausageinfo", endpoint_index=0):
class ValueContractTests(unittest.TestCase):
def test_cycle_tracker_requires_monotonic_cycle_and_stable_epoch(self):
tracker = CycleTracker()
first = tracker.observe({"scanner_cycle": 4, "scanner_epoch": "epoch-a"}, 0)
first = tracker.observe({"scanner_cycle": 4, "scanner_epoch": 1}, 0)
self.assertFalse(first["advanced"])
self.assertTrue(tracker.observe({"scanner_cycle": 4, "scanner_epoch": "epoch-a"}, 0)["previous_cycle"] == 4)
self.assertTrue(tracker.observe({"scanner_cycle": 5, "scanner_epoch": "epoch-a"}, 0)["advanced"])
self.assertEqual(tracker.observe({"scanner_cycle": 4, "scanner_epoch": 1}, 0)["previous_cycle"], 4)
self.assertTrue(tracker.observe({"scanner_cycle": 5, "scanner_epoch": 1}, 0)["advanced"])
with self.assertRaisesRegex(ProbeError, "regressed"):
tracker.observe({"scanner_cycle": 3, "scanner_epoch": "epoch-a"}, 0)
tracker.observe({"scanner_cycle": 3, "scanner_epoch": 1}, 0)
with self.assertRaisesRegex(ProbeError, "epoch"):
tracker.observe({"scanner_cycle": 6, "scanner_epoch": "epoch-b"}, 0)
tracker.observe({"scanner_cycle": 6, "scanner_epoch": 2}, 0)

def test_unpublished_snapshot_preserves_the_last_observed_cycle_and_epoch(self):
tracker = CycleTracker()
tracker.observe({"scanner_cycle": 4, "scanner_epoch": 1}, 0)
pending = tracker.observe(unpublished_snapshot(), 0)
self.assertIsNone(pending["scanner_cycle"])
self.assertEqual(pending["previous_cycle"], 4)
self.assertFalse(pending["advanced"])
with self.assertRaisesRegex(ProbeError, "regressed"):
tracker.observe({"scanner_cycle": 3, "scanner_epoch": 1}, 0)
with self.assertRaisesRegex(ProbeError, "changed scanner epoch"):
tracker.observe({"scanner_cycle": 5, "scanner_epoch": 2}, 0)

def test_cycle_tracker_rejects_missing_and_malformed_cycle(self):
tracker = CycleTracker()
for value in (None, -1, True, "7"):
for value in (None, -1, True, "7", 1.0):
with self.subTest(value=value), self.assertRaisesRegex(ProbeError, "scanner cycle"):
tracker.observe({"scanner_cycle": value}, 0)
tracker.observe(unpublished_snapshot() | {"scanner_cycle": value}, 0)
for changes in ({"usage_snapshot_complete": True}, {"last_update": certificate()["certified_at"]},
{"buckets_usage": {"bucket": {"objects_count": 0}}}, {"scanner_epoch": 1}):
with self.subTest(changes=changes), self.assertRaisesRegex(ProbeError, "scanner cycle"):
tracker.observe(unpublished_snapshot() | changes, 0)

def test_cycle_tracker_rejects_malformed_epoch(self):
tracker = CycleTracker()
for epoch in (-1, True, "1", 1.0):
with self.subTest(epoch=epoch), self.assertRaisesRegex(ProbeError, "invalid scanner epoch"):
tracker.observe({"scanner_cycle": 1, "scanner_epoch": epoch}, 0)

def test_absence_and_missing_counters_do_not_become_zero(self):
view = bucket_view({"buckets_usage": {}}, "bucket")
Expand Down Expand Up @@ -273,6 +299,39 @@ def test_versioned_scenario_preserves_historical_payloads_and_marker_counts(self
expected = json.loads(oracles[0].read_text())["expected"]
self.assertEqual((expected["count"], expected["versions"], expected["markers"]), (6, 8, 1))

def test_blackbox_cases_wait_for_the_first_published_snapshot(self):
def configure(client):
original = client.admin
initial = iter(range(2))

def admin(*args, **kwargs):
if next(initial, None) is None:
return original(*args, **kwargs)
value = unpublished_snapshot()
client.last_evidence = client.evidence.save("fake-admin", value)
return value

client.admin = admin

for case in select_cases("blackbox"):
with self.subTest(case=case.design_id):
result = self.run_case(case, configure=configure, convergence_timeout=0.2)
self.assertEqual(result["verdict"], "PASS", result)
sample_path, = (self.directory / "evidence" / case.id).glob("*-usage-samples.json")
samples = json.loads(sample_path.read_text())
self.assertEqual([sample["scanner_cycle"] for sample in samples[:2]], [None, None])
self.assertFalse(any(sample["view"]["converged"] for sample in samples[:2]))
self.assertTrue(samples[-1]["view"]["converged"])

def test_unpublished_usage_cannot_pass_without_convergence(self):
def configure(client):
client.admin = lambda **_: unpublished_snapshot()

result = self.run_case(CASES[19], configure=configure)
self.assertEqual(result["verdict"], "FAIL", result)
self.assertIn("did not converge", result["reason"])
self.assertEqual(result["cleanup_status"], "PASS")

def test_product_error_and_cleanup_failure_cannot_pass(self):
for attr, verdict in (("fail_put", "FAIL"), ("fail_cleanup", "INFRA_ERROR"), ("malformed", "INFRA_ERROR")):
with self.subTest(attr=attr):
Expand Down
6 changes: 3 additions & 3 deletions validation-migration-review.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"source_sha256": "463fdd02dee43e42fef4f3aacf7506709ce87af535e1a53d91c521bc2e361cad",
"reviewed_testing_commit": "5e76033d7ccad414aad1f7edb9867de6462eee43",
"scope": "Test implementation migration and candidate live acceptance are independent. This review does not rewrite original results, change migration_status semantics or relax the canonical gate. Environment procedures remain disabled by default under the accepted delivery scope.",
"evidence_basis": "20261026-canonical-migration-ledger-7094.json plus later G01/G02 attempts and source review on 2026-10-28; historical result bytes and audit reports remain in the separate evidence store. 2026-11-10: a scoped re-review of the Rebalance activity fixture, capacity admission, Started non-zero progress, and the early-completion diagnosis; this local regression adds no product live acceptance. 2026-11-22: reviewed the replication inventory pagination, Heal census completeness, expected-manifest comparison, ILM control survival, and exact marker oracles after automated review findings. Reviewed the 10-version NewerNoncurrentVersions retention procedure and source/target version-purge convergence evidence for this change. 2026-11-22: indexed the source-audit inventory and added individually dispatchable local compatibility and source-suite procedure entries with selector and candidate-admission checks. 2026-11-22: added table-catalog and upgrade procedure selectors with shared validation artifact wiring; dry-run selectors cover all 25 newly indexed procedures. 2026-11-22: clarified that source-native tests are used as assertion and boundary-value references; one-to-one native ports are outside the migration scope. 2026-11-24: re-reviewed the ILM scanner-readiness preflight after a 4-node VM run (auto-testing 644b935, RustFS 2d90297) blocked all 14 ILM cases because followers report effective_interval_available=false with a zero effective interval by design; the effective-interval comparison now runs only on the leader. This is a test-oracle correction and adds no product live acceptance. 2026-11-24: refreshed the reviewed digest for rustfs-s3-compat-test.sh to match current main (a3a9e83 and 6feeeec changed that script without updating this ledger); this PR does not modify the script, and the same digest mismatch reproduces on a clean origin/main checkout. 2026-11-24: refreshed the reviewed digest again for rustfs-s3-compat-test.sh after 90b4fe1 changed that script without updating this ledger; the main push of ba6051d failed the contract-tests job. This follow-up does not modify the script. 2026-11-24: accepted the product last_cycle_partial_reason=unknown sentinel in the ILM scanner-readiness preflight after a healthy leader was still blocked; this is a test-oracle correction and adds no product live acceptance. 2026-11-24: reviewed the new STOR-135 DeepKeyListingResilience case in rustfs-storage-test.sh (backlog#3293): a 301-segment key PUT followed by a recursive ListObjectsV2 must either return the key or fail with a controlled error while the server stays alive, and GET must return the same bytes. This is a test-oracle addition guarding the scan_dir recursion-depth fix; it adds no product live acceptance. 2026-11-25: fixed the S3C-206 fixture to send the single encoded metadata value it expects; the previous fixture sent two encoded words and the product preserved them exactly, so the case falsely failed. 2026-11-23: added strict SSE contract procedures ENC-201..ENC-210 (S3 compatibility suite) and KMS-601..KMS-609 (KMS suite), executed by scripts/sse_contract_cases.py and individually dispatchable; they were exercised against local single-process servers started with each suite's environment, which is no fleet live acceptance. 2026-11-26: indexed STOR-136 for disk-compressed Range GET on a single-node single-disk deployment, with exact response bytes and a positive bounded process read-byte delta.",
"evidence_basis": "20261026-canonical-migration-ledger-7094.json plus later G01/G02 attempts and source review on 2026-10-28; historical result bytes and audit reports remain in the separate evidence store. 2026-11-10: a scoped re-review of the Rebalance activity fixture, capacity admission, Started non-zero progress, and the early-completion diagnosis; this local regression adds no product live acceptance. 2026-11-22: reviewed the replication inventory pagination, Heal census completeness, expected-manifest comparison, ILM control survival, and exact marker oracles after automated review findings. Reviewed the 10-version NewerNoncurrentVersions retention procedure and source/target version-purge convergence evidence for this change. 2026-11-22: indexed the source-audit inventory and added individually dispatchable local compatibility and source-suite procedure entries with selector and candidate-admission checks. 2026-11-22: added table-catalog and upgrade procedure selectors with shared validation artifact wiring; dry-run selectors cover all 25 newly indexed procedures. 2026-11-22: clarified that source-native tests are used as assertion and boundary-value references; one-to-one native ports are outside the migration scope. 2026-11-24: re-reviewed the ILM scanner-readiness preflight after a 4-node VM run (auto-testing 644b935, RustFS 2d90297) blocked all 14 ILM cases because followers report effective_interval_available=false with a zero effective interval by design; the effective-interval comparison now runs only on the leader. This is a test-oracle correction and adds no product live acceptance. 2026-11-24: refreshed the reviewed digest for rustfs-s3-compat-test.sh to match current main (a3a9e83 and 6feeeec changed that script without updating this ledger); this PR does not modify the script, and the same digest mismatch reproduces on a clean origin/main checkout. 2026-11-24: refreshed the reviewed digest again for rustfs-s3-compat-test.sh after 90b4fe1 changed that script without updating this ledger; the main push of ba6051d failed the contract-tests job. This follow-up does not modify the script. 2026-11-24: accepted the product last_cycle_partial_reason=unknown sentinel in the ILM scanner-readiness preflight after a healthy leader was still blocked; this is a test-oracle correction and adds no product live acceptance. 2026-11-24: reviewed the new STOR-135 DeepKeyListingResilience case in rustfs-storage-test.sh (backlog#3293): a 301-segment key PUT followed by a recursive ListObjectsV2 must either return the key or fail with a controlled error while the server stays alive, and GET must return the same bytes. This is a test-oracle addition guarding the scan_dir recursion-depth fix; it adds no product live acceptance. 2026-11-25: fixed the S3C-206 fixture to send the single encoded metadata value it expects; the previous fixture sent two encoded words and the product preserved them exactly, so the case falsely failed. 2026-11-23: added strict SSE contract procedures ENC-201..ENC-210 (S3 compatibility suite) and KMS-601..KMS-609 (KMS suite), executed by scripts/sse_contract_cases.py and individually dispatchable; they were exercised against local single-process servers started with each suite's environment, which is no fleet live acceptance. 2026-11-26: indexed STOR-136 for disk-compressed Range GET on a single-node single-disk deployment, with exact response bytes and a positive bounded process read-byte delta. 2026-11-26: re-reviewed the shared scanner cycle oracle after four-node USAGE-01/20 retests. An explicitly incomplete empty response without a scan identity remains eligible for polling, published epochs use integer identifiers, and exact convergence, monotonicity, and cleanup assertions remain required. The existing migration and live acceptance states are unchanged.",
"reviewed_files": {
"scripts/run_validation_case.sh": "58e0eb2fb007b28fb16b0fd4a25ac2f997cc9f01a4a3700c01fe7c9a6dd1a683",
"scripts/validation_heal/authority.py": "8f2225f184427674de1f45aff4c4976c812f9d70fd4bc927ce460726a4ff74a0",
Expand Down Expand Up @@ -116,11 +116,11 @@
"scripts/validation_replication/replication_behavior.py": "c42d29b43b8828f4d1293eb4a8a8c801277611d734e550f0ee6a0e09f733a584",
"scripts/validation_replication/oracles.py": "f90539bd72ba8b5a4c5decf66d559cd7083379f809ef699dd1da62f80893a7d3",
"scripts/validation_scanner_usage/runner.py": "fabc8f2e0936aec686a1ba26b24130d69c564d89e017443e4247dc635990285e",
"scripts/validation_scanner_usage/cycle.py": "0fa7bff744ba9c81bac202f86b99beb0d787d36071073484c0ada0b067009b45",
"scripts/validation_scanner_usage/cycle.py": "f8ec961e3760ca9ee7d7fe0477f21b256f7a00d3765a6a009fcdf5629450bfe5",
"test_validation_heal_availability.py": "42e394d6c00359a6cb958d294af5c4eb5602c8cdb2b7c413d07584e2c9f79acc",
"test_validation_ilm.py": "f4d361850f278a5be965f05ff8950d91347907be2253bfa31a1864ae5b2a730c",
"test_validation_replication.py": "83e1b532e8a6a352c5e38de48799356157e1fad4f1f314ea8ad256fdecf942c5",
"test_validation_scanner_usage.py": "cd5cb785184586cf90824c347bf584642545acffdf6302ad361de39773d4732e",
"test_validation_scanner_usage.py": "e549bab36f5896844ff70ab6bf1d6b1825747e5cc5e9a5003a8336d70e8b8173",
"rustfs-s3-compat-test.sh": "31f986f574484da43f36fcc1ee74b0a088d83574202a91945a3473b49cab82aa",
"rustfs-security-test.sh": "02cddd15636df1e74210c172ee898dba9b3adf83943da45d874d6c827583d9d2",
"rustfs-tier-test.sh": "3b37a6b26a4af862d7f2d178872900f314c8328ffd3db6a3e769928a5d1b3964",
Expand Down