Skip to content

Commit 3b40686

Browse files
acn-ericlawclaude
andcommitted
memory: the answer of a function that answers for itself (#158) and an answer's annotations by the Java rule (#159), both merged
Two session logs. 2026-12-05-011126: an interceptor's answer carries its execution, and the host writes the function's record for a wire request-response call to an interceptor. 2026-12-05-013504: 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 5e67a06 commit 3b40686

3 files changed

Lines changed: 209 additions & 1 deletion

File tree

‎memory/continuity.md‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,20 @@
190190
exists - every traced execution leaves exactly one; before changing a host or client path, ask which side records it in
191191
the Java engine and mirror that side; a lineage check parses every record of the trace from every process and verifies
192192
each parent is a span some record owns.
193-
<!-- id: trace-records-engine-parity | created: 2026-11-14 | last_used: 2026-11-25 | uses: 3 | tier: archive-candidate | origin: 2026-11-14-115318 -->
193+
**Extended 2026-12-05 (the twin of the engines' fix for their HTTP client, mercury-composable #715 and #716):**
194+
a function that answers for itself is recorded by the same rule. `stampAnswer` in `bus.ts`, called by
195+
`registry.sendEvent`, gives an interceptor's answer - an unmarked envelope sent from inside the execution to the
196+
request's reply address - the execution's span, annotations and elapsed time, and the sender and the trace where it
197+
has none; the host writes the function's round trip for an interceptor called with the `rpc` tag. A new reply path
198+
goes through `sendEvent`, never around it. #158, merge `1dbb20a`, MERGED 2026-12-05; the Python twin is
199+
mercury-python #98.
200+
**An answer carries the annotations of its execution and no others (the maintainer, 2026-12-05: the packs follow
201+
the Java reference implementation):** the worker and `stampAnswer` set an answer's annotations from the
202+
execution, as the Java engine's `WorkerHandler` does; this pack had merged them with the envelope's own keys
203+
winning, and the Python pack the other way round. A returned envelope transports its body, its headers and its
204+
status. An execution without a trace answers with its annotations too, as the Java worker attaches them; a test
205+
pins it. #159, merge `5e67a06`, MERGED 2026-12-05; the Python twin is mercury-python #99.
206+
<!-- id: trace-records-engine-parity | created: 2026-11-14 | last_used: 2026-12-05 | uses: 5 | tier: active | origin: 2026-11-14-115318 -->
194207

195208
- **The transcript audit store: every model turn recorded by a composable function behind a local event, off the
196209
turn's path, into PostgreSQL beside the working store - the Node twin of the Python pack's build (RFC-0012 in
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Session (2026-12-05T01:11:26.000Z)
2+
3+
**Agent:** Claude Code
4+
**Title:** The answer of a function that answers for itself carries its execution - built test first, the twin
5+
of mercury-python's fix and 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 Python twin's log is 2026-12-05-011101.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.sendEvent()` 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+
- **Not here:** the Python pack's caller records held their annotations under `notes`; this pack's `emit`
24+
writes `annotations`, and the reference test passed before the change.
25+
26+
## What was built
27+
28+
- **`bus.ts`:** an interceptor's execution is kept in an `AsyncLocalStorage` beside the trace (`Execution`: the
29+
trace context, the request's reply address, the start). `stampAnswer` gives an unmarked envelope that is sent
30+
from inside the execution to that reply address the execution's span, its annotations and the elapsed time,
31+
and the sender and the trace where it has none. The error envelope of an uncaught exception is built after
32+
the handler's context has ended, so it is stamped with the execution handed over. A worker starts with a
33+
clean context, as it does for the trace.
34+
- **`registry.ts`:** `sendEvent` calls `stampAnswer`, so every reply path goes through it.
35+
- **`server.ts`:** for a call with the `rpc` tag to an interceptor, the host writes the function's round-trip
36+
record for a single-shot answer and for a timeout, as `deliver` does for a function that returns its answer.
37+
- **Not touched, by rule:** an envelope to another route; a stream's segments, which the stream writer stamps;
38+
the `exec_time` and the sender of an answer that another function wrote.
39+
- **The pages:** the streaming guide says what the answer carries; the tracing section of the configuration
40+
guide gains the rule; one entry under Fixed in the CHANGELOG.
41+
42+
## Decisions
43+
44+
- **The maintainer's:** the check, and the fix.
45+
- **Mine:**
46+
- **The stamp is in the one place every reply passes,** `sendEvent`, and it reads the execution from the
47+
asynchronous context, so a handler needs no new call.
48+
- **Which envelope is the answer:** unmarked, to the request's reply address, sent from inside the
49+
execution. Anything else is left alone.
50+
- **The span is the execution's, the time is kept when the envelope has one.** The record is the caller's
51+
record of its call to this function; a relayed answer says how long its writer took.
52+
- **The annotations follow this pack's worker:** the reply's own keys win, as in `execute`. The Python
53+
pack's worker lets the execution's keys win, and its stamp follows that. The difference is older than
54+
this change and is not closed here.
55+
- **The marker is read in `bus.ts`:** `event-stream.ts` imports the bus and the registry, so importing
56+
`streamSignal` into the bus would close a cycle that the registry's default instance cannot start in.
57+
- **The host's record under the `rpc` tag only,** so a call that is no request-response keeps the one
58+
record its execution writes; a test holds that.
59+
- **A declared limit, not engineered:** a handler that returns before its answer is sent. The answer is
60+
stamped with the time until it was sent; the worker's own record, written for a call with a reply
61+
route, holds the time until the handler returned.
62+
- **Seen beside it, not changed:** a single-shot answer relayed by the host keeps the sink's route name in its
63+
`to` field on the wire, where a stream's envelopes are cleared of it.
64+
65+
## Verification
66+
67+
- `test/interceptor-answer.test.ts`, nine tests with functions that work for 300 ms: seven failed against the
68+
pack as it was; the reference test of a function that returns its answer and the guard of a call without the
69+
`rpc` tag passed before and after.
70+
- `npm test`: 2,945 tests, 2,869 passed, 76 skipped, none failed.
71+
- `mkdocs build --strict`: exit 0. By script, everything from `## 4.12.31` down equals the tag's text.
72+
- Not run: a live drive from an engine.
73+
74+
## The commit
75+
76+
- One commit, `57a4d45`, on the branch `fix/interceptor-answer-trace-context` from `main` at `7ac67b4`, seven
77+
files; no memory file in it. The Python twin is `675ee99` on a branch of the same name in its repository.
78+
- **Pushed and raised on the maintainer's word ("Open both PRs"),** after the remote was read: `origin/main`
79+
at the branch's base, no branch of that name, no open pull request. #158, one commit, its title the commit's;
80+
the Python twin is mercury-python #98, and each names the other. Read once after the push: mergeable, one
81+
memory check passed, the test and docs jobs running, none failing. Not merged.
82+
- **Merged by the maintainer:** #158, merge `1dbb20a`, 2026-12-05T01:29:09Z; the next log, 2026-12-05-013504.md,
83+
reads it on the remote and continues from it.
84+
85+
## Doc Gaps
86+
87+
(none)
88+
89+
## Memory References
90+
91+
- Referenced:
92+
- `trace-records-engine-parity`: the rule that every traced execution leaves exactly one record and that
93+
the side which records it mirrors the Java engine decided the stamp, the host's record under the `rpc`
94+
tag and the guard test; the fact gains the interceptor's answer.
95+
- Created: (none).
96+
- Reactivated:
97+
- `trace-records-engine-parity`: an archive candidate, relied on and extended here.
98+
- 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:35:04.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 #158 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-011126.md (the answer of a function that answers for itself). The Python twin's
13+
log is 2026-12-05-013448.md in its repository.
14+
15+
## The merge, read on the remote first
16+
17+
- #158 MERGED 2026-12-05T01:29:09Z, merge `1dbb20a` over `57a4d45`; the tree equals the commit that was raised.
18+
The Python twin, mercury-python #98, merge `df90f71`, merged the same minute.
19+
- **The maintainer agreed with the decisions of that pull request.**
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:** `{ ...info.annotations, ...reply.annotations }`, so a key that the envelope
31+
carried stayed on the answer, over the execution's value for the same key. The Python pack merged the other
32+
way round, with the execution's value winning.
33+
34+
## What was built
35+
36+
- **`bus.ts`:** the worker sets a returned answer's annotations from the execution, and `stampAnswer` does the
37+
same for the answer an interceptor sends.
38+
- **The pages:** the function patterns guide states the rule beside `annotateTrace()`; one entry under Fixed in
39+
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+
- `test/interceptor-answer.test.ts` gains four cases - a returned and a sent envelope that carry annotations of
65+
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+
- `npm test`: 2,951 tests, 2,875 passed, 76 skipped, none failed.
69+
- `mkdocs build --strict`: exit 0. By script, everything from `## 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, `0d13dda` (amended once for the pinning test and the entry's wording), on the branch `fix/answer-annotations-java-rule` from `main` at `1dbb20a`, four files;
75+
no memory file in it. The Python twin is `a35e1d8` 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, no open pull request. #159, one commit, its title the commit's;
78+
the Python twin is mercury-python #99, and each names the other. Read once after the push: mergeable, the
79+
memory checks passed, the test job running and the docs job queued, none failing. Not merged.
80+
- **Merged by the maintainer, read on the remote:** #159 MERGED 2026-12-05T01:56:59Z, merge `5e67a06` over
81+
`0d13dda`, every check passed; the tree equals the commit that was raised. The Python twin, mercury-python #99,
82+
merge `c79d0a5`, merged the same minute.
83+
- **The checkout:** on `main` at `5e67a06`, 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)