Skip to content

The agent that grows with you

fix(cache): signatures stored and compared later always hash

Tekniumf09d03dfe2c2
diff --git a/agent/prompt_builder.py b/agent/prompt_builder.py
index 517b07132b8..eb8de4439c2 100644
--- a/agent/prompt_builder.py
+++ b/agent/prompt_builder.py
@@ -1110,7 +1110,7 @@ def _build_skills_manifest(skills_dir: Path) -> dict[str, list[int]]:
try:
if filename in files:
st = os.stat(path)
- manifest[path[prefix_len:]] = list(file_cache_version(path, st))
+ manifest[path[prefix_len:]] = list(file_cache_version(path, st, always_digest=True))
except OSError:
pass
return manifest
diff --git a/gateway/run_profile_reconcile.py b/gateway/run_profile_reconcile.py
index ccb37e9c62f..59dd4cf7af5 100644
--- a/gateway/run_profile_reconcile.py
+++ b/gateway/run_profile_reconcile.py
@@ -41,7 +41,7 @@ _OWN_GATEWAY_PROBE_TIMEOUT_SECS = 5.0
def _stat_signature(path: Path) -> Optional[tuple]:
try:
- return file_cache_version(path)
+ return file_cache_version(path, always_digest=True) # stored, compared on a later tick
except OSError:
return None
diff --git a/hermes_cli/free_tier_bootstrap.py b/hermes_cli/free_tier_bootstrap.py
index 539ff70e511..92ab64e4ce2 100644
--- a/hermes_cli/free_tier_bootstrap.py
+++ b/hermes_cli/free_tier_bootstrap.py
@@ -135,7 +135,7 @@ def _config_stamp() -> tuple:
stamp = []
for name in _INVENTORY_FILES:
try:
- stamp.append(file_cache_version(home / name))
+ stamp.append(file_cache_version(home / name, always_digest=True))
except OSError:
stamp.append(None)
return tuple(stamp)
diff --git a/tui_gateway/methods_onboarding.py b/tui_gateway/methods_onboarding.py
index f3333120e98..83b27ed27fe 100644
--- a/tui_gateway/methods_onboarding.py
+++ b/tui_gateway/methods_onboarding.py
@@ -79,7 +79,7 @@ def _shared_nous_store() -> tuple[Path, ...]:
def _version(path):
from utils import file_cache_version
try:
- return file_cache_version(path)
+ return file_cache_version(path, always_digest=True) # stamp stored, compared later
except OSError:
return None
diff --git a/website/docs/developer-guide/config-backend.md b/website/docs/developer-guide/config-backend.md
index a3c692f8ec9..158fd4fa42c 100644
--- a/website/docs/developer-guide/config-backend.md
+++ b/website/docs/developer-guide/config-backend.md
@@ -20,7 +20,7 @@ already reaches it.
| `read_config_doc(path)` | Parsed user layer (raises like `open` + `fast_safe_load`) |
| `read_config_doc_readonly(path)` | Signature-cached read; never mutate the result |
| `config_version(path)` | Change signature (the file's stat tuple) |
-| `config_cache_version(path)` (`config_cache_version_or_none`) | Signature for a cache of the parse: the stat tuple plus a content digest while the mtime is younger than `utils.RACY_MTIME_WINDOW_NS` (`utils.file_cache_version` on the file backend) |
+| `config_cache_version(path)` (`config_cache_version_or_none`) | Signature for a cache of the parse: the stat tuple plus a content digest while the later of mtime and ctime is younger than `utils.RACY_MTIME_WINDOW_NS` (`utils.file_cache_version` on the file backend) |
| `config_exists(path)` | Whether the layer exists |
| `probe_config_readable(path)` | Raise `OSError` while the layer cannot be read (no parse) |
| `write_config_document(path, doc)` / `write_config_key(path, key, value)` | Writes; callers normally use `atomic_config_write` / `atomic_config_replace` |
@@ -33,7 +33,11 @@ pins the older parse for the life of the process (a rotated `api_key` is the usu
Any other file a cache derives from (`auth.json`, pairing lists, `.env`, token files, the managed
overlay) keys on `utils.file_cache_version(path)`; a signature stored and compared much later (a
change detector whose false positive reconnects something, a parse-failure record) passes
-`always_digest=True`, because the racy digest turns empty once the file settles. The managed scope (`/etc/hermes`) stays an overlay on top
+`always_digest=True`, because the racy digest turns empty once the file settles (the skills
+manifest, hook-consent, free-tier and onboarding stamps do). "Recent" is judged on ctime as well as
+mtime, because `cp -p` or `rsync --inplace -t` restore an older mtime after writing. A worker bound to
+a frozen config snapshot never hashes a `config.yaml`: its key stays stat-only there, so the content
+check never makes such a worker open the profile file. The managed scope (`/etc/hermes`) stays an overlay on top
of whatever user layer the backend returns.
## Lints