Repository navigation
feat(proto): carry Bind and Unbind on the plugin service — the contract row becomes callable - #366
Conversation
…ntract row becomes callable
P09 unit 1, producer-first, `spec` only. The wire shapes were merged by spec#352
(`schema/bind.cue`: `#BindInput`, `#BindOutput`, `#UnbindInput`); this declares the methods that
carry them.
## Why the proto had zero `Bind` methods, stated as the finding
DESIGN.md:413, verbatim:
| binding | core → plugin | a need or use paired with its provide, delivered by `bind` to the
owner of the capability type (§8) | the type owner's manifest; the nodes' provide:/need:/use: |
**`Bind` is zero in the proto because nobody has wired it, not because DESIGN decided against it.**
The row says a binding is *delivered by `bind` to the owner of the capability type*; the transport
had no method to deliver it. Before this change the shapes had no consumer anywhere (`git -C spec
grep -n 'BindInput\|BindOutput\|UnbindInput' origin/main -- '*.go' '*.cue'` → the definition+generated
pair only; sdk 0; charly 0). This is the first of six units that makes the row callable.
## What was added, and the mirror it copies
Authoring surface: **`protocol/schema/plugin.cue`** — `proto/plugin.proto` is generated (`// Code
generated by spec/internal/wiregen … DO NOT EDIT`, and charly.yml:82 says "generated output, never
an authoring surface"). So the diff is the CUE model plus its regeneration.
Two methods on the `Provider` service, after the existing three:
{ "name": "Bind", "request": "BindRequest", "response": "BindReply" }
{ "name": "Unbind", "request": "UnbindRequest", "response": "Empty" }
Three messages, carrying CUE-shaped payloads as `bytes` + JSON — the house pattern, copied
verbatim from `InvokeRequest`/`InvokeReply`:
{ "name": "InvokeReply", "fields": [ { "name": "result_json", "type": "bytes", "number": 1 } ] }
message BindRequest { bytes input_json = 1; } // the marshalled #BindInput
message BindReply { bytes output_json = 1; } // the marshalled #BindOutput — the binding
message UnbindRequest { bytes input_json = 1; } // the marshalled #UnbindInput
**`BindReply` has ONE field, mirroring `InvokeReply`, and no `error`.** Measured: `InvokeReply`
carries only `result_json`; `ProviderServer.Invoke` returns `(*InvokeReply, error)`
(`proto/plugin_grpc.pb.go:221`), so a failure crosses as the gRPC status, not as a reply field.
(`HostBuildReply` on the EXECUTOR service does carry `string error = 2`, because that leg is the
reverse channel where a build failure is data — a different service, not this mirror.)
**No destination field, by design**: D-CAP-4 — *"Bindings are state, delivered by the type's
`bind`; they never appear in an authored file"* — so the reply IS the binding (an opaque handle),
and how the owner effectuates it (a file at `dst`, a venue's container env) is the owner's
business. Plan-step env is a defect, not a target: it can only be reached by putting the value in
the IR.
## R7 — a real round trip, and both halves
`proto/bind_wire_test.go`: `#BindInput` → JSON → `BindRequest.input_json` → `proto.Marshal` →
`Unmarshal` → decode back → every field asserted, and the decoded payload then **validated against
the shipped CUE** (`#BindInput`/`#BindOutput`/`#UnbindInput`). Same for the reply and the unbind
input. No server: the generated stubs are the whole path.
Planted, run, reverted:
PLANT A — the decoder looks for the wrong key (`provided` instead of `provided_by`):
--- FAIL: BindInput: need, provided_by, deployment
provided_by did not survive: "", want "podman"
PLANT B — the schema stops closing `need.type` (`#Word` -> `string`):
--- FAIL: a need type outside #Word
the boundary accepted a #BindInput the schema refuses — the payload is transported, not validated
RESTORED:
--- PASS (all three round trips + all three absence cases + the positive control)
The absence half is its own test (`TestBindInputIsValidatedAtTheBoundary`): bytes that transport
perfectly but name a `need.type` outside `#Word`, a `provided_by` that is not a `#Ref`, or a missing
required field, must be REFUSED at the boundary — with a positive control so a
validate-always-fails helper cannot pass it.
## Gates, on the final tree
wire-gen rc=0 (a SECOND run is a no-op: the same four files, no extra drift)
cue-gen task cue-gen: 2 step(s), 0 failed — and TestGenReproducible passes
go build ./... rc=0
go vet ./... rc=0
go test ./... -count=1 rc=0 0 failures, 20 packages ok
golangci-lint (GOTOOLCHAIN=go1.26.8, GOSUMDB unset) 0 issues
gofmt -l . (empty)
Diff: `protocol/schema/plugin.cue` (+45) and the regenerated `proto/plugin.proto` (+19),
`proto/plugin.pb.go`, `proto/plugin_grpc.pb.go`, plus the new test.
## What this buys
After this, `bind` is **callable**: the wire carries it and `TestProtoMatchesSchema` keeps it
carrying it. Unit 2 (`ClassType` + the solver's call in `charly`) can dispatch to a provider;
`plugin-secrets` is a dozen lines after that. Six units, and this is the first.
Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
Review — BLOCKHead SHA: Change class: CUE transport-model addition in Blocks
Notes (non-blocking): The generated artifacts check out against the source — I recomputed the raw descriptor: the Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
…e method surface, not just the bytes)
Review round on the wire seam. The first commit proved the payload survives `Marshal`→`Unmarshal`;
it never touched `ProviderClient.Bind`, `ProviderServer.Bind` or `_Provider_Bind_Handler`, so the
generated METHOD SURFACE — the thing this change adds — could have been deleted with the test still
passing. That was the finding, and it was right: a payload test cannot see a method.
## The test
`proto/bind_grpc_test.go` runs an in-process gRPC server over `bufconn` (no port, no external
service, nothing to skip: the service under test is one the test starts) with a stub type owner
whose `Bind` decodes `input_json` into `#BindInput`, echoes `provided_by` into the returned
binding, and returns it; a real `ProviderClient` then CALLS it.
- `client.Bind(ctx, &BindRequest{InputJson: payload})` → the reply's `output_json` decodes to a
binding carrying `podman` and `bed`, so the test reads the REPLY rather than merely completing
the call;
- `client.Unbind(...)` → a non-nil `Empty`;
- a stub whose `Bind` returns `status.Error(codes.FailedPrecondition, …)` → the client sees that
code — **the failure channel the one-field `BindReply` depends on**. If that ever stops being
true, `BindReply` needs the error field, and this test is where that is decided.
## Both plants, and they are different from the payload plants
PLANT C — the CUE drops the `Bind` method row, then wire-gen:
vet: proto/bind_grpc_test.go:96:23: client.Bind undefined
(type ".../proto".ProviderClient has no field or method Bind)
— a COMPILE failure, which is the proof that deleting the method breaks a real caller.
PLANT D — the stub's Bind returns an empty #BindOutput:
--- FAIL: Bind over gRPC
the reply's binding = map[], want the provide the request carried (podman) — the test must
read the REPLY, not merely complete the call
RESTORED: all nine assertions pass (three round trips, three absence cases, two method calls, the
status channel, plus the positive control). The payload plants A and B from the first commit are
unchanged and still bite; the section below keeps them.
## Descriptor evidence (independently checkable)
`Provider`'s service length prefix `\xd7\x01` → `\xcf\x02` (+120 bytes = two 58-byte method
descriptors), and the message count 37 → 40 with the indices shifted consistently — the stubs
describe exactly the methods and messages the CUE declares.
## Gates, on the final tree
wire-gen rc=0, and a SECOND run is a no-op (no tracked file moves)
go build ./... rc=0
go vet ./... rc=0
go test ./... -count=1 rc=0 0 failures, 32 packages ok
golangci-lint (GOTOOLCHAIN=go1.26.8, GOSUMDB unset) 0 issues
gofmt -l . (empty)
Tier: `fully tested and validated` — the new code path EXECUTED, over the connection it will
actually cross, with the failure channel asserted.
Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
Review — BLOCKHead SHA: Change class: CUE transport-model addition in The prior bot block (on Blocks
(All other rules — A1 body completeness aside from the above, A2 class/gate, A3, R0, R1, R2, R3, R4, R5 sweep of identifiers, R6, R7, R8 in-process, R9/R10 no-binary module honesty with the pasted Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
…nd ship no plant scaffolding
Review round on the wire seam. The first commit proved the payload survives `Marshal`→`Unmarshal`;
it never touched `ProviderClient.Bind`, `ProviderServer.Bind` or `_Provider_Bind_Handler`, so the
generated METHOD SURFACE — the thing this change adds — could have been deleted with the test still
passing. This round fixes that, and removes the scaffolding its own plant left behind.
## The test
`proto/bind_grpc_test.go` runs an in-process gRPC server over `bufconn` (no port, no external
service, nothing to skip: the service under test is one the test starts) with a stub type owner
whose `Bind` decodes `input_json` into `#BindInput`, echoes `provided_by` into the returned binding,
and returns it; a real `ProviderClient` then CALLS it.
- `TestBindOverARealConnection` — the reply's `output_json` decodes to a binding carrying `podman`
and `bed` (the test reads the REPLY, not merely a nil error), and `Unbind` returns a non-nil
`Empty`;
- `TestBindFailureCrossesAsTheStatus` — a stub returning `status.Error(codes.FailedPrecondition, …)`
surfaces to the client with that code: **the failure channel the one-field `BindReply` depends
on.** If that ever stops being true, `BindReply` needs the error field, and this test is where
that is decided.
The stub carries ONE field, `failWith`, and both its constructions set it or leave it a documented
zero: `&bindServer{}` (the success path) and `&bindServer{failWith: want}` (the status path). There
is no branch no test takes — the `empty` flag that Plant D used to demonstrate the reply assertion
was scaffolding, and **scaffolding that ships is deferred work**; it was removed, and the plant's
durable evidence is the pasted FAIL below, not the mechanism that produced it.
## R7 — two layers, four plants, ALL re-run after the removal
**Layer 1, the payload** (`proto/bind_wire_test.go`): `#BindInput` → JSON → `input_json` →
`proto.Marshal` → `Unmarshal` → decode (one `carry` helper, three call sites; one generic
`decodeAs[T]`, three call sites) → fields asserted → the decoded payload VALIDATED against the
shipped CUE.
PLANT A — the decoder looks for the wrong key (`provided` instead of `provided_by`):
--- FAIL: BindInput: need, provided_by, deployment
provided_by did not survive: "", want "podman"
PLANT B — the schema stops closing `need.type` (`#Word` -> `string`, then cue-gen):
--- FAIL: a need type outside #Word
the boundary accepted a #BindInput the schema refuses — the payload is transported, not validated
**Layer 2, the method** (`proto/bind_grpc_test.go`):
PLANT C — the CUE drops the `Bind` method row, then wire-gen:
vet: proto/bind_grpc_test.go:91:23: client.Bind undefined
(type ".../proto".ProviderClient has no field or method Bind)
— a COMPILE failure, which is the proof that deleting the method breaks a real caller.
PLANT D — the stub's Bind returns an empty #BindOutput:
--- FAIL: Bind over gRPC
the reply's binding = map[], want the provide the request carried (podman) — the test must
read the REPLY, not merely complete the call
RESTORED after each: all nine assertions pass (three round trips, three absence cases, two method
calls, the status channel, plus the positive control).
## Descriptor evidence (independently checkable)
`Provider`'s service length prefix `\xd7\x01` → `\xcf\x02` (+120 bytes = two 58-byte method
descriptors), and the message count 37 → 40 with the indices shifted consistently — the stubs
describe exactly the methods and messages the CUE declares.
## Files
- `protocol/schema/plugin.cue` — the authoring surface: two methods on `Provider`, three `bytes`+JSON
messages.
- `proto/plugin.proto`, `proto/plugin.pb.go`, `proto/plugin_grpc.pb.go` — regenerated.
- `proto/bind_wire_test.go` — the payload layer: round trips plus the schema-validity absence cases.
- `proto/bind_grpc_test.go` — the method layer: two calls over bufconn, the reply decoded and
asserted, the status channel proven, and **no field the tests do not set**.
## Gates, on the final tree
wire-gen rc=0, and a SECOND run is a no-op (no tracked file moves)
go build ./... rc=0
go vet ./... rc=0
go test ./... -count=1 rc=0 0 failures, 32 packages ok
golangci-lint (GOTOOLCHAIN=go1.26.8, GOSUMDB unset) 0 issues
gofmt -l . (empty)
Tier: `fully tested and validated` — the new code path EXECUTED, over the connection it will
actually cross, with the failure channel asserted.
Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
Review — PASSHead SHA: Security screen: PASS Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
Summary
A contract row becomes callable — and until now it was not even reachable.
DESIGN.md:413says a binding is "a need or use paired with its provide, delivered bybindto the owner of the capability type (§8)", andDESIGN.md:693(D-CAP-4) says "Bindings are state, delivered by the type'sbind; they never appear in an authored file." The shapes those sentences imply are already merged (spec#352:#BindInput{need!, provided_by!, deployment!},#BindOutput{binding!},#UnbindInput{binding!}).But nothing could call
bind. Measured before this change:Zero
Bindin the protocol. So no out-of-process plugin could ever be handed a#BindInputhowever its manifest read. The shapes were a contract no transport carried.Why the zero was DELEGATION, not a missing shape
A grep returning zero can mean "the contract delegates this" — and here it does:
DESIGN.md:413states the delivery, so the wire method is implied.Bindwas zero because nobody had wired it, not because DESIGN decided against it. That is the difference between "we added a method" and "we made a contract row callable", and it is why this is the producer-first leg of a six-unit chain rather than an invention.The authoring surface is the CUE transport model, not the proto
So the change is
protocol/schema/plugin.cue, rendered byinternal/wiregenthroughcharly task wire-gen;TestProtoMatchesSchemafails on drift. A hand edit of the proto would have been reverted by the next regeneration.What was added
Two methods on the
Providerservice, three messages,bytes+ JSON throughout — theInvokeRequest.params_json/InvokeReply.result_jsonpattern, with no typed mirrors:UnbindreturnsEmpty.BindReplyis ONE field, and the mirror is quoted in full so it can be checked:{ "name": "InvokeReply" "doc": "CheckResult / InstallPlan / Diagnostics, JSON" "fields": [ { "name": "result_json" "type": "bytes" "number": 1 }, ], },One field, no error channel — and
ProviderServer.Invoke(ctx, *InvokeRequest) (*InvokeReply, error)shows why: a failure crosses as the gRPC status. An earlier draft of this message carried anerrorfield; it was removed because it would have invented a shape beside the pattern it claimed to mirror. (HostBuildReply'serror = 2is the executor reverse-channel service, where a build failure is data;Frame.error = 14is the streaming leg. Neither is this mirror.)No destination field. The reply IS the binding, the binding is state (D-CAP-4), and a destination reachable only through the plan is a destination that requires the value in the IR — so how the type owner effectuates delivery is the owner's business, not this message's payload.
How tested
The first lint pass flagged
dupl×2 andunconvert×1 on the new test; the three round trips now share onecarryhelper and a genericdecodeAs, and lint is clean. Named because a lint finding fixed silently is a lint finding a reader cannot verify.Independent evidence that the generated stubs describe the methods the CUE declares — three numbers to check instead of a diff to trust: the
Providerservice length prefix moves\xd7\x01→\xcf\x02(+120 = two 58-byte method descriptors), and the message-type count moves 37 → 40 with thegoTypes/depIdxsindices shifted consistently.R7 — the round trip, and the ABSENCE half
Two layers, because a payload that survives the wire says nothing about whether a method carries it.
proto/bind_wire_test.gocarries each payload#BindInput→ JSON →input_json→proto.Marshal→Unmarshal→ decode, assertsneed/provided_by/deploymentfield-for-field, then validates the decoded payload against the shipped CUE.proto/bind_grpc_test.goexercises the METHOD, over a real connection: an in-process gRPC server onbufconn— no port, no external service, nothing to skip, because the service under test is one the test starts — registers a stub type owner whoseBinddecodesinput_jsoninto#BindInputand echoesprovided_byinto the returned binding, and a realProviderClientthen calls it.client.Bind(...)'s reply is decoded and asserted (podman,bed),client.Unbind(...)returns a non-nilEmpty, and a stub returningstatus.Error(codes.FailedPrecondition, …)surfaces with that code to the client — the channel the one-fieldBindReplydesign depends on. If that ever stops being true,BindReplyneeds the field and this test is where it is decided.(This module pins
grpc v1.61, which predatesgrpc.NewClient; the dial isDialContext+WithBlockover the same bufconn listener — same connection, older spelling, and the code says why.)A and B prove the payload; C and D prove the method. Plant C is a compile failure, and that is the strongest form of "a test that fails without the change": with the CUE row gone,
client.Binddoes not exist, so the caller the test is cannot be written. Plant D proves the test reads the reply rather than merely completing the call.Plant B is the assertion that earns the sentence. A round trip proves bytes move; it does not prove the payload is validated. The absence half refuses three shapes that transport perfectly — a
need.typeoutside#Word, aprovided_bythat is not a#Ref, and a payload missing a required field — and a positive control so a validate-always-fails helper cannot pass it.R10 honesty, premise and exit status pasted
opencharly/specis the contract module: nodisposable:target, no service, no binary. Its gate is the module suite plus wire-gen reproducibility, both pasted. Thegrepexits 1 — no match is not a success.Rulebook compliance
/charly-internals:go(SDD: CUE is authoritative, the proto is rendered),/charly-internals:plugin(the provider protocol this extends).bytes+ JSON, copyingInvokeRequest/InvokeReplyrather than adding typed mirrors beside them.origin/main9b3403a; no other session's worktree touched.Change classification
Kind: a CUE transport-model addition in
specplus its regenerated proto and stubs.Breaking change + rollback: none. Two methods are ADDED to the
Providerservice and three messages to the file; no existing method, field or number changes, so every current plugin keeps working untouched. A provider that does not implementBindfails only if something calls it — and nothing does yet (unit 2 is the caller). Rollback deletes the two method rows and three messages fromprotocol/schema/plugin.cueand re-runswire-gen.Filed issues
optional, so a secret delivery decides #SecretUse.optional at compile time (residual race) #363 —FileStephas nooptional, so the file-delivery leg decides#SecretUse.optionalat compile time with a named residual race.InjectSecretsIntoPlansputs secret VALUES into the IR (D-SEC-1); delete it once the capability-type owner delivers instead.Files changed
protocol/schema/plugin.cueBind/Unbindmethods onProvider;BindRequest/BindReply/UnbindRequestasbytes+JSON, mirroringInvokeRequest/InvokeReplyproto/plugin.protowire-gen— two methods, three messagesproto/plugin.pb.goproto/plugin_grpc.pb.goproto/bind_wire_test.goproto/bind_grpc_test.goBind/Unbindcalled over a realbufconnconnection, the reply decoded and asserted, and the gRPC status channel proven (the METHOD layer)Agent: lead
Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated)