Datasets:
Download src/explicit_learning/interventions/redact_solid.py from sungguk/visual-answerability: direct link, hf CLI and curl.
- Browser
- Download file 2.06 kB
-
https://huggingface.co/datasets/sungguk/visual-answerability/resolve/main/src/explicit_learning/interventions/redact_solid.py
- Command line
-
hf download hf://datasets/sungguk/visual-answerability/src/explicit_learning/interventions/redact_solid.py
-
curl -L -o redact_solid.py https://huggingface.co/datasets/sungguk/visual-answerability/resolve/main/src/explicit_learning/interventions/redact_solid.py
2.06 kB
| """``REDACT_SOLID_V1`` — remove an observed value while keeping node identity. | |
| The node's identity/position remains available to the renderer as a stable | |
| redaction anchor, but its value is removed from the transformed epistemic world. | |
| Consequently an executor cannot read hidden evidence through a privileged | |
| structured-state side channel. Alternative completion worlds restore different | |
| values under the same visibility marker and must render byte-identically. | |
| """ | |
| from __future__ import annotations | |
| from typing import Any | |
| from ..sources.base import World | |
| from ..sources.world_ops import node_kind, world_sha256 | |
| from .base import ( | |
| InterventionError, | |
| OperatorName, | |
| TransformedWorld, | |
| remove_observed_value, | |
| set_hidden, | |
| transformed_hash, | |
| ) | |
| _NAME: OperatorName = "REDACT_SOLID_V1" | |
| class RedactSolidOperator: | |
| """Hide ``target_node``'s pixels without removing it from the world.""" | |
| name = _NAME | |
| def apply( | |
| self, | |
| world: World, | |
| target_node: str, | |
| *, | |
| seed: int, | |
| **_kwargs: Any, | |
| ) -> TransformedWorld: | |
| if node_kind(world, target_node) is None: | |
| raise InterventionError(f"REDACT_SOLID_V1: target {target_node!r} is not a world node") | |
| hidden = frozenset({target_node}) | |
| new_world = set_hidden(remove_observed_value(world, target_node), hidden) | |
| return TransformedWorld( | |
| world=new_world, | |
| operator=_NAME, | |
| target_node=target_node, | |
| seed=seed, | |
| transformed_world_sha256=transformed_hash( | |
| operator=_NAME, | |
| target_node=target_node, | |
| seed=seed, | |
| source_world_sha256=world_sha256(world), | |
| transformed_world_sha256=world_sha256(new_world), | |
| hidden_nodes=hidden, | |
| substitute_value=None, | |
| ), | |
| hidden_nodes=hidden, | |
| substitute_value=None, | |
| description=f"redact-solid {target_node}", | |
| ) | |
| __all__ = ["RedactSolidOperator"] | |