Skip to content

Multi-tier framework for evaluating AI agent skills and plugins with quality gates, security scanning, harness compatibility checks, semantic overlap detection, synthetic evaluation dataset generation, and live agent evaluation that measures how skills affect agent behavior. Ships reusable CI templates that bring every check to any repository.

test(tier3): model advanced ctime in the restored-mtime summary race (#654)

Christopher Kevind41ec54b1533
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9069ec45..11a61b97 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -369,6 +369,8 @@ All notable changes to SkillEvaluator are documented in this file.
depending on filesystem clock granularity.
- Make the onboarding URL-rewrite test use its temporary global Git config even
when the caller sets `GIT_CONFIG_GLOBAL`.
+- Model a changed ctime explicitly in the restored-mtime summary regression so
+ it does not depend on two writes crossing a filesystem clock tick.
- The Tier 2 scale guide names the fixed 8 MiB selected-manifest input budget
and 1 MiB per-manifest limit, including in description-only embedding mode.
- Saved Tier 2 catalogs use compact JSON so indentation no longer rejects dense
diff --git a/docs/developer-guide.mdx b/docs/developer-guide.mdx
index 2735bd7e..ba29663e 100644
--- a/docs/developer-guide.mdx
+++ b/docs/developer-guide.mdx
@@ -76,8 +76,9 @@ mtime: two same-size writes can otherwise share a filesystem clock tick.
| `integration` | End-to-end integration tests; may need fixtures or longer runtime | `pytest -m integration` |
| `live` | Live tests against the in-process Harbor backend; requires the `tier3` extra and `NVIDIA_API_KEY` | `pytest -m live` |
-The MCP-staging restored-mtime regression models an advanced ctime explicitly,
-so its source-change assertion does not depend on the host clock ticking.
+The MCP-staging and legacy-summary restored-mtime regressions model an advanced
+ctime explicitly, so their source-change assertions do not depend on the host
+clock ticking.
Git URL-rewrite tests point `GIT_CONFIG_GLOBAL` at their temporary configuration,
so caller-level Git isolation does not suppress the rewrite being tested.
diff --git a/tests/test_results_location_legacy_compatibility.py b/tests/test_results_location_legacy_compatibility.py
index 033a860b..bf238abe 100644
--- a/tests/test_results_location_legacy_compatibility.py
+++ b/tests/test_results_location_legacy_compatibility.py
@@ -802,6 +802,26 @@ def test_rejects_legacy_run_config_replaced_before_open(
assert not _is_completed(run)
+def _stat_with_advanced_ctime(metadata: os.stat_result, advance_ns: int) -> os.stat_result:
+ """Copy every stat field and advance only ``st_ctime_ns``.
+
+ ``os.stat_result(sequence, extras)`` fills the fields that are not part of
+ the 10-item sequence (``st_mtime_ns``, ``st_ctime_ns``, ...) only from
+ ``extras`` and leaves the rest ``None``, so each one is copied explicitly.
+ Otherwise a missing ``st_mtime_ns`` would be rejected by the mtime
+ comparison and hide whether the ctime comparison works.
+ """
+ sequence_fields = set(os.stat_result.__match_args__)
+ extras = {
+ name: getattr(metadata, name)
+ for name in dir(metadata)
+ if name.startswith("st_") and name not in sequence_fields
+ }
+ extras["st_ctime_ns"] += advance_ns
+ return os.stat_result(tuple(metadata), extras)
+
+
[email protected](os.name != "posix", reason="descriptor-anchored ctime validation only runs on POSIX")
def test_rejects_same_inode_summary_rewrite_with_restored_mtime(
monkeypatch: pytest.MonkeyPatch,
tmp_path: Path,
@@ -813,9 +833,55 @@ def test_rejects_same_inode_summary_rewrite_with_restored_mtime(
summary_inode = summary_metadata.st_ino
original = summary.read_text(encoding="utf-8")
rewritten = original.replace("0.8", "0.9")
+ assert rewritten != original
assert len(rewritten) == len(original)
+ # Same device, inode, mode, link count, size and restored mtime as the file
+ # the reader opened; only the ctime moved, so only a ctime comparison can
+ # reject the read.
+ advanced_ctime_metadata = _stat_with_advanced_ctime(summary_metadata, 2_000_000_000)
+ assert advanced_ctime_metadata.st_ctime_ns != summary_metadata.st_ctime_ns
+ for attribute in dir(summary_metadata):
+ if attribute.startswith("st_") and "ctime" not in attribute:
+ assert getattr(advanced_ctime_metadata, attribute) == getattr(summary_metadata, attribute), attribute
+ assert os.path.samestat(advanced_ctime_metadata, summary_metadata)
real_read = os.read
+ real_fstat = os.fstat
+ real_lstat = Path.lstat
+ real_stat = os.stat
rewritten_once = False
+ post_read_fstat_done = False
+
+ def fstat_with_advanced_ctime(fd: int) -> os.stat_result:
+ # The first descriptor stat after the rewrite is secure_fs's post-read
+ # check and reports the advanced ctime. Later observations (the
+ # re-read that results_location does to confirm its snapshot) report
+ # the original stat, so no other ctime comparison can reject the run.
+ nonlocal post_read_fstat_done
+ metadata = real_fstat(fd)
+ if not rewritten_once or metadata.st_ino != summary_inode:
+ return metadata
+ if post_read_fstat_done:
+ return summary_metadata
+ post_read_fstat_done = True
+ return advanced_ctime_metadata
+
+ def lstat_with_original_ctime(path: Path) -> os.stat_result:
+ # results_location compares the path's lstat ctime after the read too.
+ # On a host whose clock ticked between the two writes that comparison
+ # would reject the rewrite on its own and hide the secure_fs check.
+ metadata = real_lstat(path)
+ if rewritten_once and metadata.st_ino == summary_inode:
+ return summary_metadata
+ return metadata
+
+ def stat_with_original_ctime(path, *args, **kwargs) -> os.stat_result:
+ # The confirmation re-read also checks the path with os.stat before
+ # opening it. Hide the real rewrite's ctime there too, so removing
+ # only the post-read ctime check makes this regression fail.
+ metadata = real_stat(path, *args, **kwargs)
+ if rewritten_once and metadata.st_ino == summary_inode:
+ return summary_metadata
+ return metadata
def rewrite_during_read(fd: int, length: int) -> bytes:
nonlocal rewritten_once
@@ -826,8 +892,22 @@ def test_rejects_same_inode_summary_rewrite_with_restored_mtime(
return real_read(fd, length)
monkeypatch.setattr(results_location.os, "read", rewrite_during_read)
+ monkeypatch.setattr(results_location.os, "fstat", fstat_with_advanced_ctime)
+ monkeypatch.setattr(Path, "lstat", lstat_with_original_ctime)
+ monkeypatch.setattr(results_location.os, "stat", stat_with_original_ctime)
assert not _is_completed(run)
+ assert rewritten_once
+ assert post_read_fstat_done
+ # The patched os.stat, Path.lstat and os.fstat above report the original
+ # metadata for this inode, so a plain ``summary.stat()`` here would only echo
+ # that back. Check the real file with the stat captured before patching to
+ # show the rewrite happened and the mtime really was restored.
+ final_metadata = real_stat(summary)
+ assert final_metadata.st_ino == summary_inode
+ assert final_metadata.st_size == summary_metadata.st_size
+ assert final_metadata.st_mtime_ns == summary_metadata.st_mtime_ns
+ assert summary.read_text(encoding="utf-8") == rewritten
def test_rejects_summary_parent_swapped_to_link_before_read(