Skip to content

Commit 1b448bf

Browse files
acn-ericlawclaude
andcommitted
memory: the answer of a function that answers for itself (#98) and an answer's annotations by the Java rule (#99), both merged
Two session logs. 2026-12-05-011101: an interceptor's answer carries its execution, the host writes the function's record for a wire request-response call to an interceptor, and a caller's record holds its annotations under "annotations". 2026-12-05-013448: the worker and the stamp set an answer's annotations from the execution, as the Java engine's worker does; a finding about that engine corrected by a probe and pinned by a test. Continuity: trace-records-engine-parity gains both and is active again; the fact footers are refreshed from the reference logs. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
1 parent c79d0a5 commit 1b448bf

4 files changed

Lines changed: 215 additions & 4 deletions

File tree

‎memory/continuity.md‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,20 @@
197197
record, never whether one exists - every traced execution leaves exactly one; before changing a host or client path, ask
198198
which side records it in the Java engine and mirror that side; a lineage check parses every record of the trace from every
199199
process and verifies each parent is a span some record owns.
200-
<!-- id: trace-records-engine-parity | created: 2026-11-14 | last_used: 2026-11-25 | uses: 3 | tier: archive-candidate | origin: 2026-11-14-115310 -->
200+
**Extended 2026-12-05 (the twin of the engines' fix for their HTTP client, mercury-composable #715 and #716):**
201+
a function that answers for itself is recorded by the same rule. `stamp_answer` in `bus.py`, called by
202+
`registry.send_event`, gives an interceptor's answer - an unmarked envelope sent from inside the execution to the
203+
request's reply address - the execution's span, annotations and elapsed time, and the sender and the trace where it
204+
has none; the host writes the function's round trip for an interceptor called with the `rpc` tag; a caller's record
205+
holds its annotations under `annotations` (`notes` in 4.12.30 and 4.12.31). A new reply path goes through
206+
`send_event`, never around it. #98, merge `df90f71`, MERGED 2026-12-05; the Node twin is mercury-nodejs #158.
207+
**An answer carries the annotations of its execution and no others (the maintainer, 2026-12-05: the packs follow
208+
the Java reference implementation):** the worker and `stamp_answer` set an answer's annotations from the
209+
execution, as the Java engine's `WorkerHandler` does; this pack had merged them, and the Node pack the other way
210+
round. A returned envelope transports its body, its headers and its status. An execution without a trace
211+
answers with its annotations too, as the Java worker attaches them; a test pins it. #99, merge `c79d0a5`,
212+
MERGED 2026-12-05; the Node twin is mercury-nodejs #159.
213+
<!-- id: trace-records-engine-parity | created: 2026-11-14 | last_used: 2026-12-05 | uses: 5 | tier: active | origin: 2026-11-14-115310 -->
201214

202215
- **The transcript audit store: every model turn recorded by a composable function behind a local event, off the
203216
turn's path, into PostgreSQL beside the working store (RFC-0012 in mercury-composable, Eric's rulings of 2026-11-17;
@@ -510,7 +523,7 @@
510523
the subject's is the shape to look for (a `robots.txt` reader written in this round took 32 seconds a question
511524
before it was replaced). A test of a refusal picks a case that a count decides, never a depth of nesting or a
512525
clock: the twin's CI failed on an expression that one platform's stack refused and another's compiled.
513-
<!-- id: conv-one-rule-and-a-bound | created: 2026-11-30 | last_used: 2026-11-30 | uses: 1 | tier: working | origin: 2026-11-30-083700 -->
526+
<!-- id: conv-one-rule-and-a-bound | created: 2026-11-30 | last_used: 2026-11-30 | uses: 1 | tier: active | origin: 2026-11-30-083700 -->
514527

515528
- **Every YAML file is read by YAML 1.2.2 - the core schema - and written to it (the maintainer's rulings of
516529
2026-11-29; PR #92, merge `00e9afb`; the engine's fact is mercury-composable's `conv-yaml-1-2-2`).** The
@@ -533,7 +546,7 @@
533546
*Write YAML 1.2.2, and none of the additional syntax of YAML 1.1* in the configuration reference is the page
534547
to point to. "The Java engine does it" binds this pack where a guide or a shipped file states the behaviour,
535548
never where it is the leniency of the engine's library.
536-
<!-- id: conv-yaml-1-2-2-python | created: 2026-11-30 | last_used: 2026-11-30 | uses: 1 | tier: working | origin: 2026-11-30-083700 -->
549+
<!-- id: conv-yaml-1-2-2-python | created: 2026-11-30 | last_used: 2026-11-30 | uses: 1 | tier: active | origin: 2026-11-30-083700 -->
537550

538551
## Open Threads
539552

‎memory/open-threads/thread-reverify-invariants-20261125.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
scope fence is unchanged (ingress, never orchestration - a flow binding refused by name) and the engine-consistent
55
conventions now carry the REST grammar, its messages and its error body. No wording changed; core stays 4. Lesson: the
66
edge added a surface, not an exception. origin: 2026-11-25-034612 (raised); closed 2026-11-25-042423.
7-
<!-- id: reverify-invariants-20261125 | created: 2026-11-25 | last_used: 2026-11-25 | uses: 2 | tier: active | origin: 2026-11-25-034612 -->
7+
<!-- id: reverify-invariants-20261125 | created: 2026-11-25 | last_used: 2026-11-25 | uses: 2 | tier: archive-candidate | origin: 2026-11-25-034612 -->
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Session (2026-12-05T01:11:01.000Z)
2+
3+
**Agent:** Claude Code
4+
**Title:** The answer of a function that answers for itself carries its execution, and a caller's record holds
5+
its annotations under `annotations` - built test first, the twin of the engines' fix for their HTTP client
6+
**User:** the maintainer, in a session of the Java engine's repository: "the language packs have a minimalist
7+
in-memory event bus. Please also check if this flaw also applies to them."; then, to the question whether to fix
8+
the flaw in both packs next: "Fix the packs"; then "Open both PRs".
9+
10+
The lead record is the Java repository's log 2026-12-05-004003.md and its thread
11+
`pack-interceptor-answer-trace-context`. The Node twin's log is 2026-12-05-011126.md in its repository.
12+
13+
## What was found
14+
15+
- **The flaw, by a probe (2026-12-04).** An interceptor receives the raw envelope and answers through its reply
16+
address; the caller writes the record of a request-response call from the first reply. A reply that a handler
17+
builds and sends with `registry.send_event()` carried nothing of its execution, so the record held no
18+
`exec_time`, no `span_id` and no annotations. The reply carried no trace either, so a function that received
19+
it through a reply route ran untraced.
20+
- **Found at the build, the wire path.** A request-response call that arrives at `/api/event` for an
21+
interceptor left no record of the function at all: the execution writes none under the `rpc` tag, and the
22+
host wrote the function's round trip only for a function that returns its answer. A timeout left none either.
23+
- **Found at the build, a second defect.** `EventBus.emit` wrote the annotations of a caller's record under the
24+
key `notes`. A quality round of 2026-11-16 renamed a parameter that shadowed `annotations` and the key with
25+
it, two days after the record was introduced, so 4.12.30 and 4.12.31 carry it. Every other record, the Node
26+
pack and the engines write `annotations`, and the forwarder's span mapping reads that key.
27+
28+
## What was built
29+
30+
- **`bus.py`:** an interceptor's execution is kept in a context variable beside the trace (`_Execution`: the
31+
trace context, the request's reply address, the start). `stamp_answer` gives an unmarked envelope that is
32+
sent from inside the execution to that reply address the execution's span, its annotations and the elapsed
33+
time, and the sender and the trace where it has none. A worker starts with a clean context, as it does for
34+
the trace. `emit` writes `annotations`.
35+
- **`registry.py`:** `send_event` calls `stamp_answer`, so every reply path goes through it: a handler's own
36+
envelope and the error envelope of an uncaught exception.
37+
- **`server.py`:** for a call with the `rpc` tag to an interceptor, the host writes the function's round-trip
38+
record for a single-shot answer and for a timeout, as `_deliver` does for a function that returns its answer.
39+
- **Not touched, by rule:** an envelope to another route; a stream's segments, which the stream writer stamps;
40+
the `exec_time` and the sender of an answer that another function wrote.
41+
- **The pages:** the streaming guide names `registry.send_event()` and says what the answer carries; the
42+
tracing section of the configuration guide gains the rule; two entries under Fixed in the CHANGELOG.
43+
44+
## Decisions
45+
46+
- **The maintainer's:** the check, and the fix.
47+
- **Mine:**
48+
- **The stamp is in the one place every reply passes,** `send_event`, and it reads the execution from a
49+
context variable, so a handler needs no new call and a sync handler on an executor thread is covered.
50+
- **Which envelope is the answer:** unmarked, to the request's reply address, sent from inside the
51+
execution. Anything else is left alone.
52+
- **The span is the execution's, the time is kept when the envelope has one.** The record is the caller's
53+
record of its call to this function; a relayed answer says how long its writer took, as the Rust
54+
engine's client leaves it.
55+
- **The annotations follow this pack's worker:** the execution's keys win, as in `_execute`. The Node
56+
pack's worker lets the reply's own keys win, and its stamp follows that. The difference is older than
57+
this change and is not closed here.
58+
- **The host's record under the `rpc` tag only,** so a call that is no request-response keeps the one
59+
record its execution writes; a test holds that.
60+
- **The `notes` key rides in this commit:** the record it repairs is the one the new tests read. It can be
61+
split out on the maintainer's word.
62+
- **A declared limit, not engineered:** a handler that returns before its answer is sent. The answer is
63+
stamped with the time until it was sent; the worker's own record, written for a call with a reply
64+
route, holds the time until the handler returned.
65+
- **Seen beside it, not changed:** a single-shot answer relayed by the host keeps the sink's route name in its
66+
`to` field on the wire, where a stream's envelopes are cleared of it.
67+
68+
## Verification
69+
70+
- `tests/test_interceptor_answer.py`, nine tests with functions that work for 300 ms: eight failed against the
71+
pack as it was, and the ninth, which guards a call without the `rpc` tag against a second record, passed
72+
before and after.
73+
- `pytest`: 3,025 passed, 76 skipped. `ruff check .`: clean. `basedpyright`: 0 errors.
74+
- `mkdocs build --strict`: exit 0. By script, everything from `## Version 4.12.31` down equals the tag's text.
75+
- Not run: a live drive from an engine.
76+
77+
## The commit
78+
79+
- One commit, `675ee99`, on the branch `fix/interceptor-answer-trace-context` from `main` at `3d1f701`, seven
80+
files; no memory file in it. The Node twin is `57a4d45` on a branch of the same name in its repository.
81+
- **Pushed and raised on the maintainer's word ("Open both PRs"),** after the remote was read: `origin/main`
82+
at the branch's base, no branch of that name, one open pull request of another branch. #98, one commit, its
83+
title the commit's; the Node twin is mercury-nodejs #158, and each names the other. Read once after the push:
84+
mergeable, the memory and docs checks passed, the two test jobs running, none failing. Not merged.
85+
- **Merged by the maintainer:** #98, merge `df90f71`, 2026-12-05T01:29:19Z; the next log, 2026-12-05-013448.md,
86+
reads it on the remote and continues from it.
87+
88+
## Doc Gaps
89+
90+
(none)
91+
92+
## Memory References
93+
94+
- Referenced:
95+
- `trace-records-engine-parity`: the rule that every traced execution leaves exactly one record and that
96+
the side which records it mirrors the Java engine decided the stamp, the host's record under the `rpc`
97+
tag and the guard test; the fact gains the interceptor's answer.
98+
- Created: (none).
99+
- Reactivated:
100+
- `trace-records-engine-parity`: an archive candidate, relied on and extended here.
101+
- Superseded: (none).
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Session (2026-12-05T01:34:48.000Z)
2+
3+
**Agent:** Claude Code
4+
**Title:** An answer carries the annotations of its execution and no others, the Java engine's rule - the two
5+
packs' workers merged them in opposite orders; built test first, and #98 merged before it
6+
**User:** the maintainer, in a session of the Java engine's repository: "agree with your decisions for notes in
7+
python, etc. PR 98 and 158 merged. Your finding: \"The two packs' workers merge an answer's annotations in
8+
opposite orders: the execution's keys win in Python, the reply's own in Node.\" Please make them consistent to
9+
follow the Java reference implementation."; then, on a finding of mine that proved wrong: "Please adjust the
10+
packs accordingly and add to these two PRs for the packs."; then "Open both PRs".
11+
12+
This log continues 2026-12-05-011101.md (the answer of a function that answers for itself). The Node twin's log
13+
is 2026-12-05-013504.md in its repository.
14+
15+
## The merge, read on the remote first
16+
17+
- #98 MERGED 2026-12-05T01:29:19Z, merge `df90f71` over `675ee99`; the tree equals the commit that was raised.
18+
The Node twin, mercury-nodejs #158, merge `1dbb20a`, merged the same minute.
19+
- **The maintainer agreed with the decisions of that pull request,** the `notes` fix riding in it among them.
20+
- Local `main` fast-forwarded, the merged local branch removed, and this change started from `main` on the
21+
branch `fix/answer-annotations-java-rule`.
22+
23+
## The rule, read in the Java engine before any change
24+
25+
- `WorkerHandler` builds the response itself: from a returned `EventEnvelope` it takes the body, the headers and
26+
the status (`applyEnvelopeResult`), and `applyTraceContext` sets the response's annotations from the
27+
execution's trace - `setAnnotations` clears and then puts. So an answer holds the annotations that the
28+
execution wrote and no others, and an annotation set on a returned envelope is not transported.
29+
- The Rust engine does the same: the worker sets the reply's annotations from the trace state.
30+
- **This pack merged instead:** `reply.annotations.update(info.annotations)`, so a key that the envelope
31+
carried and the execution did not write stayed on the answer. The Node pack merged the other way round, with
32+
the envelope's own value winning.
33+
34+
## What was built
35+
36+
- **`bus.py`:** the worker sets a returned answer's annotations from the execution, and `stamp_answer` does the
37+
same for the answer an interceptor sends.
38+
- **The pages:** the function patterns guide states the rule beside `annotate_trace()`; one entry under Fixed
39+
in the CHANGELOG, with its upgrade note.
40+
41+
## Decisions
42+
43+
- **The maintainer's:** both packs follow the Java reference implementation.
44+
- **Mine:**
45+
- **The interceptor's answer follows the worker's rule too.** The stamp was written to give an answer what
46+
a worker gives a returned one, so one rule holds for both. A relayed answer keeps its writer's time and
47+
sender, as ruled before, and takes the relaying execution's annotations; the writer's own annotations
48+
are on the writer's record.
49+
- **An execution that annotates nothing answers with no annotations,** as the Java engine's `setAnnotations`
50+
clears. Tests hold both cases.
51+
- **A finding of mine corrected the same session.** I had reported that the Java engine attaches no annotations
52+
without a trace, and the maintainer asked for the packs to be adjusted to it ("Please adjust the packs
53+
accordingly and add to these two PRs for the packs"). The report was wrong, and nothing was adjusted. A
54+
trackable function in the Java engine always has a trace context, with an empty id when the request carries
55+
no trace, and its worker sets the answer's annotations from it. Probed with a temporary print in the engine's
56+
inbox, removed afterwards: the answer of a request without a trace arrived with the execution's annotation,
57+
and without the one set on the returned envelope. The packs already do the same; a test pins it.
58+
- **What does differ, reported and not changed:** in the Java engine the caller never reads those annotations.
59+
The inbox takes them off the answer for the record, and a function that receives an answer through a reply
60+
route has them cleared on entry. Here `PostOffice.request` returns the reply with them, as the guides say.
61+
62+
## Verification
63+
64+
- `tests/test_interceptor_answer.py` gains four cases - a returned and a sent envelope that carry annotations
65+
of their own, with an execution that annotates and one that does not. All four failed against the pack as it
66+
was. Two further cases pin the answer of a request without a trace and passed before and after; the
67+
file's fifteen tests pass.
68+
- `pytest`: 3,031 passed, 76 skipped. `ruff check .`: clean. `basedpyright`: 0 errors.
69+
- `mkdocs build --strict`: exit 0. By script, everything from `## Version 4.12.31` down equals the tag's text.
70+
- Not run: a live drive from an engine.
71+
72+
## The commit
73+
74+
- One commit, `a35e1d8` (amended once for the pinning test and the entry's wording), on the branch `fix/answer-annotations-java-rule` from `main` at `df90f71`, four files;
75+
no memory file in it. The Node twin is `0d13dda` on a branch of the same name in its repository.
76+
- **Pushed and raised on the maintainer's word ("Open both PRs"),** after the remote was read: `origin/main`
77+
at the branch's base, no branch of that name, one open pull request of another branch. #99, one commit, its
78+
title the commit's; the Node twin is mercury-nodejs #159, and each names the other. Read once after the push:
79+
mergeable, the memory and docs checks passed, the two test jobs running, none failing. Not merged.
80+
- **Merged by the maintainer, read on the remote:** #99 MERGED 2026-12-05T01:56:45Z, merge `c79d0a5` over
81+
`a35e1d8`, every check passed; the tree equals the commit that was raised. The Node twin, mercury-nodejs #159,
82+
merge `5e67a06`, merged the same minute.
83+
- **The checkout:** on `main` at `c79d0a5`, the merged local branch removed. The memory of this log and the one
84+
before it goes to `main` on the maintainer's word ("Yes, after merge").
85+
86+
## Doc Gaps
87+
88+
(none)
89+
90+
## Memory References
91+
92+
- Referenced:
93+
- `trace-records-engine-parity`: before changing a host or client path, ask what the Java engine does and
94+
mirror it - read in `WorkerHandler` first; the fact gains the merges and the annotation rule.
95+
- Created: (none).
96+
- Reactivated: (none).
97+
- Superseded: (none).

0 commit comments

Comments
 (0)