From d938dfb7e294b7d8cae62741c4696e961badeeae Mon Sep 17 00:00:00 2001 From: Jon Patterson Date: Mon, 23 Nov 2026 12:32:09 -0600 Subject: [PATCH 1/3] fix(evaluation): redact non-public model identities in execution evidence Local checkpoint paths and internal model names passed the old identity check and were kept in requested.model, requested.model_revision, observed.model, operator profile identities and the aggregates. Model names are now recorded only if publicly approved (nvidia/Cosmos3-Nano, plus exact names in COSMOS_EVIDENCE_PUBLIC_MODELS), and revisions only as commit hashes or 'unknown'; anything else becomes 'redacted'. Unredacted identities can be written to a separate opt-in execution_identity_dir for debugging. Addresses review feedback on #321. Signed-off-by: Jon Patterson --- .../cosmos3/reasoner/vlmevalkit/README.md | 10 ++++ .../vlmevalkit/vlmeval/api/cosmos_reason.py | 25 ++++++---- .../vlmevalkit/vlmeval/execution_evidence.py | 46 +++++++++++++++---- 3 files changed, 64 insertions(+), 17 deletions(-) diff --git a/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/README.md b/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/README.md index 87c2feaf7..9e761d6a8 100644 --- a/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/README.md +++ b/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/README.md @@ -128,6 +128,16 @@ or return API. Evidence requests raw token IDs but retains only visual groups, actual response model, usage and finish reasons—not prompts, text token IDs, labels, media, endpoint URLs or credentials. +Model identities are redacted by default. Model names (requested, returned, or in +an operator processor profile) are recorded only if they are on the public +allowlist (`nvidia/Cosmos3-Nano`), extended with exact names in the +comma-separated `COSMOS_EVIDENCE_PUBLIC_MODELS`. Only approve names that are +already public. Revisions are recorded only as commit hashes or `unknown`. Any +other value, such as a local checkpoint path, internal model name, branch or tag, +is recorded as `redacted`. To debug, set `execution_identity_dir` to a separate +directory: it receives the unredacted identities per response. That output is +not sanitized; never share it alongside the evidence. + Nano's explicit processor profile comes from the pinned public [`config.json`](https://huggingface.co/nvidia/Cosmos3-Nano/resolve/e59a53c25979a090fa8706c9acc0c254a6e89b92/config.json) and [`preprocessor_config.json`](https://huggingface.co/nvidia/Cosmos3-Nano/resolve/e59a53c25979a090fa8706c9acc0c254a6e89b92/preprocessor_config.json): diff --git a/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/vlmeval/api/cosmos_reason.py b/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/vlmeval/api/cosmos_reason.py index c76dc8ca5..966e0d1c5 100644 --- a/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/vlmeval/api/cosmos_reason.py +++ b/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/vlmeval/api/cosmos_reason.py @@ -300,6 +300,8 @@ def __init__(self, # Opt-in; never forward evidence configuration to BaseAPI or the endpoint. self.execution_evidence_dir = kwargs.pop('execution_evidence_dir', None) self.execution_processor_profile = kwargs.pop('execution_processor_profile', None) + # Separate opt-in directory for unredacted model identities; never share it. + self.execution_identity_dir = kwargs.pop('execution_identity_dir', None) self._last_execution_record = None # Default Qwen3 / Reason2 setup. self.image_patch_size = kwargs.pop('image_patch_size', None) @@ -542,18 +544,23 @@ def _record_execution(self, payload, raw, media=None): return from pathlib import Path import tempfile - from vlmeval.execution_evidence import build_execution_record + from vlmeval.execution_evidence import build_execution_record, private_identity_record + revision = os.environ.get("COSMOS_MODEL_REVISION", "unknown") record = build_execution_record(payload, raw, media=media, processor_profile=self.execution_processor_profile, - requested_model_revision=os.environ.get("COSMOS_MODEL_REVISION", "unknown")) - directory = Path(self.execution_evidence_dir) - directory.mkdir(parents=True, exist_ok=True, mode=0o700) - # O_EXCL + mode 0600 from mkstemp, unique across processes/threads/retries. - fd, path = tempfile.mkstemp(prefix='response-', suffix='.json', dir=directory) - with os.fdopen(fd, 'w') as output: - json.dump(record, output, allow_nan=False) - output.write('\n') + requested_model_revision=revision) + writes = [(self.execution_evidence_dir, record)] + if self.execution_identity_dir is not None: + writes.append((self.execution_identity_dir, private_identity_record(payload, raw, revision))) + for target, content in writes: + directory = Path(target) + directory.mkdir(parents=True, exist_ok=True, mode=0o700) + # O_EXCL + mode 0600 from mkstemp, unique across processes/threads/retries. + fd, path = tempfile.mkstemp(prefix='response-', suffix='.json', dir=directory) + with os.fdopen(fd, 'w') as output: + json.dump(content, output, allow_nan=False) + output.write('\n') self._last_execution_record = record def generate_inner(self, inputs, **kwargs) -> str: diff --git a/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/vlmeval/execution_evidence.py b/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/vlmeval/execution_evidence.py index 355b75293..b8fe113dd 100644 --- a/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/vlmeval/execution_evidence.py +++ b/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/vlmeval/execution_evidence.py @@ -20,8 +20,37 @@ } -def _identity(value): - return value if isinstance(value, str) and re.fullmatch(r'[A-Za-z0-9_./+:-]{1,240}', value) and '://' not in value else None +# Model names are recorded only when publicly approved; anything else (local +# checkpoint paths, internal names) becomes REDACTED. Approve more public names +# with COSMOS_EVIDENCE_PUBLIC_MODELS (comma-separated, exact match). +PUBLIC_MODELS = frozenset({'nvidia/Cosmos3-Nano'}) +REDACTED = 'redacted' + + +def public_models(): + extra = os.environ.get('COSMOS_EVIDENCE_PUBLIC_MODELS', '') + return PUBLIC_MODELS | {name.strip() for name in extra.split(',') if name.strip()} + + +def _model_identity(value): + if not isinstance(value, str) or not value: + return None + return value if value in public_models() else REDACTED + + +def _revision_identity(value): + """Commit hashes and 'unknown' only; branch names, tags and paths are redacted.""" + if not isinstance(value, str) or not value: + return None + return value if value == 'unknown' or re.fullmatch(r'[0-9a-f]{7,64}', value) else REDACTED + + +def private_identity_record(payload: dict, response_json: dict, requested_model_revision=None) -> dict: + """Unredacted model identities for local debugging. NOT sanitized; never share it.""" + raw = response_json if isinstance(response_json, dict) else {} + return {'format_version': 1, 'sanitized': False, + 'requested_model': payload.get('model'), 'requested_model_revision': requested_model_revision, + 'observed_model': raw.get('model')} def _number(value): @@ -89,9 +118,10 @@ def _profile(value): sources=[f'https://huggingface.co/nvidia/Cosmos3-Nano/resolve/{NANO_REVISION}/{name}' for name in ('config.json', 'preprocessor_config.json')]) else: - for key in ('profile_model', 'profile_revision'): - if _identity(value.get(key)): - result[key] = value[key] + if value.get('profile_model') is not None: + result['profile_model'] = _model_identity(value['profile_model']) + if value.get('profile_revision') is not None: + result['profile_revision'] = _revision_identity(value['profile_revision']) return result @@ -151,7 +181,7 @@ def build_execution_record(payload: dict, response_json: dict, *, media=None, pr isinstance(choice.get('message'), dict) and 'content' in choice['message'] and (choice['message']['content'] is None or isinstance(choice['message']['content'], str)) for choice in choices)) - observed = {'response_valid': bool(valid), 'model': _identity(raw.get('model')), + observed = {'response_valid': bool(valid), 'model': _model_identity(raw.get('model')), 'usage': _knobs(raw.get('usage'), ('prompt_tokens', 'completion_tokens', 'total_tokens')), 'finish_reasons': [choice.get('finish_reason') if isinstance(choice, dict) and choice.get('finish_reason') in ('stop', 'length', 'error', 'content_filter') else None @@ -202,8 +232,8 @@ def build_execution_record(payload: dict, response_json: dict, *, media=None, pr status = ('failed_response' if not valid else 'mismatch' if 'mismatch' in checks.values() else 'verified_under_explicit_profile' if all(checks[key] == 'match' for key in required) else 'unknown') return {'format_version': 1, - 'requested': {'model': _identity(payload.get('model')), 'generation': generation, - 'model_revision': _identity(requested_model_revision), + 'requested': {'model': _model_identity(payload.get('model')), 'generation': generation, + 'model_revision': _revision_identity(requested_model_revision), 'mm_processor_kwargs': processor, 'media_io_kwargs': io, 'chat_template_kwargs': _knobs(payload.get('chat_template_kwargs'), ('enable_thinking',)), 'image_inputs': images, 'video_inputs': videos, 'media': requested_media}, From 3a3202cc753e1a6d41cc316ed552504793b95442 Mon Sep 17 00:00:00 2001 From: Jon Patterson Date: Tue, 1 Dec 2026 14:22:37 -0600 Subject: [PATCH 2/3] fix(evaluation): re-sanitize identities when aggregating, reject overlapping evidence dirs aggregate_execution_records now re-applies the model/revision policy to copies of each record, so records saved by older versions or under another allowlist cannot leak identities into observed_models or requested_settings. The constructor rejects an execution_identity_dir that equals, contains, or is inside execution_evidence_dir. Addresses review feedback on #430. Signed-off-by: Jon Patterson --- .../cosmos3/reasoner/vlmevalkit/README.md | 9 ++++++--- .../vlmevalkit/vlmeval/api/cosmos_reason.py | 7 +++++++ .../vlmevalkit/vlmeval/execution_evidence.py | 13 ++++++++++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/README.md b/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/README.md index 9e761d6a8..47c7ea14d 100644 --- a/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/README.md +++ b/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/README.md @@ -134,9 +134,12 @@ allowlist (`nvidia/Cosmos3-Nano`), extended with exact names in the comma-separated `COSMOS_EVIDENCE_PUBLIC_MODELS`. Only approve names that are already public. Revisions are recorded only as commit hashes or `unknown`. Any other value, such as a local checkpoint path, internal model name, branch or tag, -is recorded as `redacted`. To debug, set `execution_identity_dir` to a separate -directory: it receives the unredacted identities per response. That output is -not sanitized; never share it alongside the evidence. +is recorded as `redacted`. `aggregate_execution_records` applies the same policy +again, so records saved by older versions or under a different allowlist are +redacted under the current one. To debug, set `execution_identity_dir` to a +separate directory: it receives the unredacted identities per response. It must +not be the evidence directory, inside it, or contain it; the constructor rejects +that. That output is not sanitized; never share it alongside the evidence. Nano's explicit processor profile comes from the pinned public [`config.json`](https://huggingface.co/nvidia/Cosmos3-Nano/resolve/e59a53c25979a090fa8706c9acc0c254a6e89b92/config.json) diff --git a/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/vlmeval/api/cosmos_reason.py b/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/vlmeval/api/cosmos_reason.py index 966e0d1c5..ab9a2f808 100644 --- a/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/vlmeval/api/cosmos_reason.py +++ b/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/vlmeval/api/cosmos_reason.py @@ -302,6 +302,13 @@ def __init__(self, self.execution_processor_profile = kwargs.pop('execution_processor_profile', None) # Separate opt-in directory for unredacted model identities; never share it. self.execution_identity_dir = kwargs.pop('execution_identity_dir', None) + if self.execution_evidence_dir is not None and self.execution_identity_dir is not None: + from pathlib import Path + evidence, identity = (Path(path).expanduser().resolve() + for path in (self.execution_evidence_dir, self.execution_identity_dir)) + # Sharing either tree must never include the other's files. + if evidence == identity or evidence in identity.parents or identity in evidence.parents: + raise ValueError('execution_identity_dir must not be, contain, or be inside execution_evidence_dir') self._last_execution_record = None # Default Qwen3 / Reason2 setup. self.image_patch_size = kwargs.pop('image_patch_size', None) diff --git a/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/vlmeval/execution_evidence.py b/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/vlmeval/execution_evidence.py index b8fe113dd..07ee33d68 100644 --- a/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/vlmeval/execution_evidence.py +++ b/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/vlmeval/execution_evidence.py @@ -248,8 +248,19 @@ def build_execution_record(payload: dict, response_json: dict, *, media=None, pr 'generation settings and model revision are requested/configured, not server-attested']}} +def _sanitized(record): + """Copy with identities re-filtered under the current policy (older or reused records).""" + requested = dict(record['requested']) + if 'model' in requested: + requested['model'] = _model_identity(requested['model']) + if 'model_revision' in requested: + requested['model_revision'] = _revision_identity(requested['model_revision']) + observed = dict(record['observed'], model=_model_identity(record['observed'].get('model'))) + return dict(record, requested=requested, observed=observed) + + def aggregate_execution_records(records, expected_requests=None): - records = [record for record in records if isinstance(record, dict) and + records = [_sanitized(record) for record in records if isinstance(record, dict) and isinstance(record.get('requested'), dict) and isinstance(record.get('observed'), dict)] counts = Counter(record.get('verification', {}).get('status', 'unknown') for record in records) return {'requests_recorded': len(records), 'expected_requests': expected_requests, From c7fe0c528bfa1feb7db488fb89642037abd7aa74 Mon Sep 17 00:00:00 2001 From: Jon Patterson Date: Wed, 2 Dec 2026 11:02:00 -0600 Subject: [PATCH 3/3] fix(evaluation): write evidence to the same resolved paths that were overlap-checked The constructor checked expanded absolute paths but _record_execution wrote with the raw strings, so execution_identity_dir='~/private' with evidence '.' outside home landed in ./~/private inside the evidence tree. Both directories are now resolved once and stored; the check and all writes use them. Addresses review feedback on #430. Signed-off-by: Jon Patterson --- .../vlmevalkit/vlmeval/api/cosmos_reason.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/vlmeval/api/cosmos_reason.py b/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/vlmeval/api/cosmos_reason.py index ab9a2f808..7ac4b8931 100644 --- a/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/vlmeval/api/cosmos_reason.py +++ b/.agents/skills/evaluation/cosmos3/reasoner/vlmevalkit/vlmeval/api/cosmos_reason.py @@ -298,14 +298,16 @@ def __init__(self, # Generic payload passthrough for vLLM-specific fields (e.g. structured_outputs). self.extra_body = kwargs.pop('extra_body', None) # Opt-in; never forward evidence configuration to BaseAPI or the endpoint. - self.execution_evidence_dir = kwargs.pop('execution_evidence_dir', None) + # Both directories are resolved once (~ expanded, absolute) and those exact paths are + # used for the overlap check and every write, so the check matches where files land. + from pathlib import Path + resolve = lambda path: None if path is None else Path(path).expanduser().resolve() + self.execution_evidence_dir = resolve(kwargs.pop('execution_evidence_dir', None)) self.execution_processor_profile = kwargs.pop('execution_processor_profile', None) # Separate opt-in directory for unredacted model identities; never share it. - self.execution_identity_dir = kwargs.pop('execution_identity_dir', None) + self.execution_identity_dir = resolve(kwargs.pop('execution_identity_dir', None)) if self.execution_evidence_dir is not None and self.execution_identity_dir is not None: - from pathlib import Path - evidence, identity = (Path(path).expanduser().resolve() - for path in (self.execution_evidence_dir, self.execution_identity_dir)) + evidence, identity = self.execution_evidence_dir, self.execution_identity_dir # Sharing either tree must never include the other's files. if evidence == identity or evidence in identity.parents or identity in evidence.parents: raise ValueError('execution_identity_dir must not be, contain, or be inside execution_evidence_dir') @@ -549,7 +551,6 @@ def prepare_inputs(self, inputs): def _record_execution(self, payload, raw, media=None): if self.execution_evidence_dir is None: return - from pathlib import Path import tempfile from vlmeval.execution_evidence import build_execution_record, private_identity_record @@ -560,8 +561,7 @@ def _record_execution(self, payload, raw, media=None): writes = [(self.execution_evidence_dir, record)] if self.execution_identity_dir is not None: writes.append((self.execution_identity_dir, private_identity_record(payload, raw, revision))) - for target, content in writes: - directory = Path(target) + for directory, content in writes: directory.mkdir(parents=True, exist_ok=True, mode=0o700) # O_EXCL + mode 0600 from mkstemp, unique across processes/threads/retries. fd, path = tempfile.mkstemp(prefix='response-', suffix='.json', dir=directory)