Commit 7579150491 for bind
commit 757915049193dc5836c54d241f7a3b996044d51a
Author: Štěpán Balážik <stepan@isc.org>
Date: Wed Nov 25 22:07:03 2026 +0100
Add the rule on wrapping handlers
What a server does to another handler's responses goes in a
ResponseHandlerWrapper around it when that helps readability and code
reuse, put together where it is installed.
Assisted-by: Claude:claude-opus-5-5
diff --git a/.agents/skills/ans-py/SKILL.md b/.agents/skills/ans-py/SKILL.md
index 04bd7c8e2c..e047229a5b 100644
--- a/.agents/skills/ans-py/SKILL.md
+++ b/.agents/skills/ans-py/SKILL.md
@@ -2922,6 +2922,57 @@ A handler the server creates many times over with different values,
...
```
+### Change another handler's responses in a wrapper
+
+What a server does to the responses of another handler, signing them,
+changing a field or holding them back, goes in a
+`ResponseHandlerWrapper` around that handler when it helps readability
+and code reuse, rather than in a subclass that takes over its
+`get_responses()`. The wrapper answers what the wrapped handler
+matches. `_on_query_received()` is awaited before the wrapped handler
+answers a query, and `_modify_response()` changes each response it
+yields; a wrapper defines the ones it needs. Wrappers are put around
+a handler where it is installed.
+
+#### Examples
+
+A wrapper that holds the answer until a control command releases it,
+`ncache/ans1/ans.py` as of fa22da84bd:
+
+```python
+# ncache/ans1/ans.py:64-75 as of fa22da84bd
+class UntilReleased(ResponseHandlerWrapper):
+ """
+ Hold the responses of the wrapped handler until the "release._control."
+ command has been received.
+ """
+
+ def __init__(self, inner: ResponseHandler, release: asyncio.Event) -> None:
+ super().__init__(inner)
+ self._release = release
+
+ async def _on_query_received(self, qctx: QueryContext) -> None:
+ await self._release.wait()
+
+# ncache/ans1/ans.py:100 as of fa22da84bd
+ server.install_response_handlers(UntilReleased(HeldAddressHandler(), release))
+```
+
+Wrappers that change each response, nested where the handler is
+installed, `xfer/ans5/ans.py` as of fa22da84bd:
+
+```python
+# xfer/ans5/ans.py:286-293 as of fa22da84bd
+ "badmessageid": (
+ SignResponses(SoaHandler()),
+ SignResponses(
+ Add50ToMessageIdFromSecondResponse(
+ XferAxfrHandler(txt_data="bad message id")
+ ),
+ ),
+ ),
+```
+
### No wall of constants
A value used once lives at its use site; a value that is an input of a