Repository navigation
Description
DONE. Closed before these files carried a status word. The .done
suffix is the record; this line is that same answer in the second place
the check reads, and no new judgement.
Found by the Claude Fable review agent (2026-08-26 review).
Problem
Several build refusals and one runtime conflation all cite the same
fact: "proto3 gives a scalar field no presence".
wire_blockerrefuses astr | None/int | Nonereturn
outright, with that sentence as the reason.WireCodec.decodereads an optional scalar as
if optional and not raw: return None- so a genuine 0, "" or
False decodes as None. The docstring admits it.check_wire_contractlets a scalar_wire_fieldsentry carry
?, which then hits the conflation above at runtime.
The cited fact is out of date. proto3 has had explicit optional
on scalar fields since protobuf 3.15 (2021): a synthetic oneof
gives the field real presence, HasField works on it, and every
implementation ships it. The schema here is built by hand as a
FileDescriptorProto, so emitting it means setting
proto3_optional = True and adding the synthetic oneof entry -
mechanical, in one place (grpc_schema._field).
Confirmed with cython-worker: the field case was on the radar
(an explicitly-passed "" reading back as None was raised twice
this session) and is unowned; the wire_blocker wording states a
limitation of proto3 where the true limitation is what this
generator emits. So there are two symptoms of one missing feature:
an optional scalar FIELD that is silently wrong, and an optional
scalar RETURN that is loudly refused. The field half is the one
that can be wrong rather than absent.
Why it matters
query_path_from_hash_part returning StorePath | None worked
only because StorePath is a message. The first real method
returning an optional scalar - a build log that may not exist, an
optional narinfo field - gets refused today, and the workaround
would be a wrapper message, which is the schema knowing something
the binding could not say.
Fix sketch
- Emit
proto3_optionalfor a scalar field whose declared type is
T | Noneor whose wire field carries?. - Decode with
HasFieldfor those, exactly as message fields do
now; delete thenot rawheuristic. - Lift the
wire_blockerrefusal for optional scalars and enums. - The refusal for an optional CONTAINER stands: repeated fields
genuinely have no presence, and "absent IS empty" is the right
answer there (041).
Ordering: do this before or with 022. It adds oneof entries to
messages, which the field-number lockfile must record.
Done
The schema emits presence. _with_presence adds the synthetic
one-field oneof and the proto3_optional flag, which is exactly what
optional string x = 1; compiles to.
Three callers stop throwing optionality away on the way in: a
_wire_fields "?", an omissible constructor parameter, and a
T | None return type. The constructor one was the quietest - the
client already skipped a None argument and the server already decoded
with optional=True, so the field had been leaning on an empty string
the whole time.
The codec reads every optional through HasField, whatever its kind.
The not raw heuristic is gone.
wire_blocker stops refusing an optional scalar or enum. The refusal
for an optional CONTAINER stands, for the reason 041 gives.
What proves it
MockDerivedPath already had the distinction and the mock already
gave the two states different meanings - no output is an OPAQUE path,
an empty output is a BUILT one whose output is unnamed - so the round
trip asserts describe() tells them apart rather than inventing a
case.
PathInfo.ca is the other half, and it is a real binding rather than
a test fixture: fixed:r:sha256:... for a path added to the store,
None for one that was BUILT, because an input-addressed output is
named after its derivation and has nothing to address by. Both arms
are asserted - the first hermetically and over the wire, the second
live.
Perturbed: with the oneof and the flag removed, protobuf itself
refuses - "Field nixmock.v1.PathInfoMsg.ca does not have presence" -
and three tests fail across two suites.
Migrated from tasks/048-proto3-optional-exists.md.done.
Assisted-By: Opus 5
Activity