Repository navigation
Description
DONE. Found by the nanopynix port (#97), 2026-09-29.
Problem
LogTap::logEI renders an ErrorInfo into text and raises a msg
record (test_logs.py::test_a_warning_takes_the_other_path). The
position, the trace, the suggestions and isFromExpr go no further.
nanopynix-bindings sends them: its log event for logEI is an error
action with the ErrorInfo dict beside the text, and nanopynix's
test_an_error_event_carries_the_same_payload_on_both_engines fails on
huggorm: "inproc sent no structured payload with its error event".
Two facts before any work
A record is visible only in the unit that declares it. ErrorInfo
is declared in path.py because the translator is there (#100).
LogRecord is bound in eval, so the eval unit cannot name
huggorm::ErrorInfo. This is the second unit that needs a record from
another one. The generic answer: emit each module's records into a
header of their own, and have a unit include the header of every
module whose records it names, as imports() does for Python. Check
first whether any record spells a union alias or needs as_tuple.
A bound value is rebuilt through its C++ constructor. LogRecord
binds the hand-written huggorm::LogRecord, crosses the wire, and
_from_parts calls its constructor with the parts. An info part
would make cpp/logging.hpp hold std::optional<huggorm::ErrorInfo>,
a generated type in a hand-written header. A nix::ErrorInfo cannot
stand in: it cannot be rebuilt from the record, because a position's
origin is gone.
So the choice is Carl's: the hand-written header includes a generated
one, or info is an in-process accessor only (@local) and nanopynix's
rpc carries the dict itself.
Adapter side
huggorm's tap raises msg for logEI; nanopynix's LogEvent.error_info
answers for an error action, with the dict as args[2]. The adapter's
_callback_args would map a record that carries info to error, with
the dict error_detail already builds.
Decision, 2026-09-29
Carl chose the records header and a wire part: emit each module's
records into a header of their own, have a unit include the headers of
the records it names, and let LogRecord hold
std::optional<huggorm::ErrorInfo>, so cpp/logging.hpp includes a
generated header. The info then crosses huggorm's wire typed, as an
error's does.
The work
Checked first: no record holds a union or a vocabulary, so a record
needs nothing the unit emits ahead of it. as_tuple is used by the
bind functions, not by a struct, so it stays in the unit.
nbemit.records_headerwrites<module>_records.hppfor each
module that declares a record, andgenerate.emit_modulewrites it
beside the unit. It carries the includes the fields need: the
casters and class headersincludesderives, and the standard
headers the struct text spells (std::int64_tneeds<cstdint>,
which no caster names; the first build of the header lacked it).records_namedlists every module whose records a unit names, its
own included, by walking every declared type. The unit includes
each of those headers.importsnow counts a record as something to import.evalnames
path'sErrorInfo, so it has to importpathfor the Python
class to exist.setup.pyputs the package directory on the include path, so a
header is namedhuggorm_bindings/path_records.hppfrom a unit and
fromcpp/logging.hppalike.LogRecordgainsstd::optional<ErrorInfo> info, and
LogTap::logEIfills it withinfo_record<ErrorInfo>(ei), and
error_infofor aBaseErrorforwards to that. WRONG FIRST: the
nix::ErrorInforeader was an overload oferror_info, and every
catch inpath.cppfailed to compile. The chain passes
error_info<ErrorInfo>as a function argument, and an overload set
deduces no type, soRead...came out empty.
The action stays"msg", as Nix'sJSONLoggerwrites it.- nanopynix's
_callback_argsmaps a"msg"that carriesinfoto
("error", level, info.msg(), dict), the other engine's shape.
Proved by breaking it: logEI without .info fails
test_a_warning_takes_the_other_path. nanopynix's
test_an_error_event_carries_the_same_payload_on_both_engines passes
on the huggorm lane, on both its inproc and rpc sessions.
Migrated from tasks/103-a-log-record-carries-error-info.md.done.
Assisted-By: Opus 5
Activity