Skip to content

fix(spec): the store wire's Opaque arms are pointers so an empty record survives the wire - #491

Merged
github-actions[bot] merged 2 commits into
mainfrom
fix/store-wire-empty-arm
Dec 2, 2026
Merged

github-actions[bot] merged 2 commits into
mainfrom
fix/store-wire-empty-arm

Conversation

@aitrawog

@aitrawog aitrawog commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A defect fix in the host-store wire structs from #483 (DESIGN §8.3 bind/realize program, #370).

The defect: StoreValueWire.State/.Config and PutInputWire.State were plain spec.Opaque maps tagged omitempty, so an empty record ({}) was dropped on encode, and the decoder then saw no arm at all. A put of an empty state record (a real value: a deployment with no bindings) therefore decoded as "no store row". statekit's host-serving tests found it (the round on opencharly/sdk#683): a permitted empty-state put was answered as an unknown row.

The fix: the three Opaque arms become *Opaque. A nil pointer is an absent arm, and a pointer to an empty map is a present, empty one. StoreKeyWire.Config was already *struct{} for the same reason.

Coordination: this PR blocks opencharly/sdk#683, whose host-serving layer is written against the pointer arms. HOLDING is posted here and WAITING on #683. Both are owned by comfyui-0471.

Files

File Change
spec/union_types.go StoreValueWire.State, StoreValueWire.Config, PutInputWire.State → *Opaque, with the reason in a comment
proto/store_grpc_test.go the stub host uses the pointer arms; new TestAnEmptyStateArmSurvivesTheWire, covering the #PutInput state, #StoreValue state and #StoreValue config arms

How tested

# head 62773f98bbeeb2623495030a21023fb48be4b902 (git rev-parse HEAD)
$ git log --oneline origin/main..HEAD
62773f9 test(spec): the empty-arm test covers StoreValueWire.Config too
9fd6b4d fix(spec): the store wire's Opaque arms are pointers so an empty record survives the wire
$ git diff --stat origin/main...HEAD
 proto/store_grpc_test.go | 40 +++++++++++++++++++++++++++++++++++-----
 spec/union_types.go      | 13 ++++++++-----
 2 files changed, 43 insertions(+), 10 deletions(-)
$ charly task cue-gen ; git status --short | wc -l
task cue-gen: 2 step(s), 0 failed, 0 skipped
0
$ go build ./... && go vet ./... ; echo rc=$?
rc=0
$ gofmt -l spec schema schemagen proto   (empty)
$ go test ./... (summary)
go test rc=0
packages ok: 35
$ go test ./proto/ -run 'HostStore|EmptyStateArm' -v
--- PASS: TestHostStoreMethodsRoundTrip (0.00s)
--- PASS: TestAnEmptyStateArmSurvivesTheWire (0.00s)
ok  	github.com/opencharly/spec/proto	0.008s
$ golangci-lint run ./...
0 issues.

C8, the Config arm (round 2): the test's #StoreValue config case against StoreValueWire.Config reverted to the plain arm, with State left a pointer so the file compiles, then restored:

$ (StoreValueWire.Config reverted to the plain Opaque arm; test value adapted) go test ./proto/ -run TestAnEmptyStateArmSurvivesTheWire
--- FAIL: TestAnEmptyStateArmSurvivesTheWire (0.00s)
    store_grpc_test.go:175: #StoreValue config: the empty config arm was dropped on the wire: {}
    store_grpc_test.go:178: #StoreValue config: want exactly the one value arm (plus key for a put), got {}
FAIL
FAIL	github.com/opencharly/spec/proto	0.007s
FAIL

C8, the defect itself. The old struct, as published in spec v0.2026336.1533 (origin/main before this fix), drops the empty arm:

$ (scratch module, spec v0.2026336.1533 = origin/main before this fix) go run .
encoded: {"key":{"identity":"comfyui","name":"binding"}}
decoded State == nil: true  (the empty record's arm is gone)
rc=0

The umbrella design controls, run on this head by pointing my session umbrella worktree's spec index entry at it (restored afterwards), against spec origin/main:

BASE spec=6600520675039547d979185a3111995bb691a0c4 dpat-rc=1 cite-rc=1
NEW spec=62773f98bbeeb2623495030a21023fb48be4b902 dpat-rc=1 cite-rc=1
index restored to 72484f63e961c4d1ea36206aa5c163fec8fbbd3c
dpat: no new finding
cite: no new finding

Both controls are red on spec main itself, tracked in opencharly/opencharly#1410. This change adds no finding to either.

Spike

RCA claim: an omitempty map arm cannot represent a present-but-empty value, so an empty state record loses its arm on the wire.

Candidates spiked:

  1. Pointer arms (*Opaque). TestAnEmptyStateArmSurvivesTheWire passes for both #PutInput and #StoreValue, and the round-trip test passes (How tested). Works.
  2. Drop omitempty from the map arms. Every encode would then emit "state":null beside the real arm, so a content put would carry "state":null and "secret":"". The closed #PutInput disjunction admits exactly one arm, as measured on feat(schema): the host state store, the type provider class and the binding record (§8.3 bind/realize B1) #483 (TestPutInputArms: "a secret put without its key"/"two stores at once" are refused). The spike, the same probe with the tag removed:
$ (scratch module) json.Marshal(struct{State map[string]any `json:"state"`; Secret string `json:"secret,omitempty"`}{Secret: "aGVsbG8="})
{"state":null,"secret":"aGVsbG8="}

A second, null arm is on the wire, and the one-arm disjunction refuses it. Fails.

Winner: (1). It is the precedent already used for StoreKeyWire.Config (*struct{}).

RCA verdict: confirmed. The empty arm survives with (1).

Rulebook compliance

Plan conformance

Winning candidate: (1) pointer arms.

Planned change DESIGN requirement Disposition
*Opaque state arm of the #PutInput wire struct (PutInputWire.State) DESIGN.cue #PutInput conforms — "#PutInputAlt: {for s, r in _store if r.put {(s): {(s)!: r.value, if !r.addressed {key!: r.key}}}}" (a put names its store by the value it writes, so the value's arm must be present even when the value is empty)
*Opaque state/config arms of the #StoreValue wire struct (StoreValueWire.State, .Config) DESIGN.cue #StoreValue conforms — "#StoreValueAlt: {for s, r in _store {(s): {(s)!: r.value}}}" (a get's answer is exactly one store's value arm, present even when that value is the empty record)
  • C0: loaded charly-internals:git-workflow, strict-policy, design, go and charly-check:check.
  • C1: a defect in my own feat(schema): the host state store, the type provider class and the binding record (§8.3 bind/realize B1) #483, found by my own downstream tests and fixed here, producer-first, before sdk#683 consumes the structs. No warning is left.
  • C2: see the Spike block.
  • C3: see the map; no DESIGN.*/design/ file is touched.
  • C4: the same pointer-arm form StoreKeyWire.Config already uses.
  • C5: no workaround.
  • C6: the map-arm form is replaced, not kept beside the pointer form.
  • C7: no documented command surface changes.
  • C8: the probe above shows the old struct drops the arm, and the new test cannot compile against it.
  • C9: N/A — no live-service boundary; the gRPC tests start their own in-process server.
  • C10: N/A, a contract module proven by its own suite.
  • C11: the module gate passes on the committed head.
  • C12: a session worktree off fresh origin/main; the review round is a new commit, no amend, no force-push, no hook bypass.

Change classification

  • Change class: contract / library module (spec). No disposable target exists: git grep -nE '^[[:space:]]*disposable:' -- '*.yml' '*.yaml' → rc=1.
  • Gate: the repo's own CI: go build ./..., go test ./..., gofmt -l and golangci-lint run ./.... All are green on head 62773f98bbeeb2623495030a21023fb48be4b902.
  • Tier: fully tested and validated. All three changed arms are exercised: TestAnEmptyStateArmSurvivesTheWire encodes and decodes the empty #PutInput state, #StoreValue state and #StoreValue config arms, and fails for each when it is reverted (the State probe and the Config mutation above). TestHostStoreMethodsRoundTrip carries the state arms across a real gRPC connection.
  • Breaking change + rollback: a Go-type change to three hand-written wire fields that no consumer uses yet. The only users are this repo's tests and the unmerged feat(statekit): the deployment state store over the state root (§8.3 bind/realize B3a) sdk#683. Rollback is reverting the commit.
  • Authoring runtime: Claude Code, model ID claude-opus-5-5 (Anthropic Claude Opus 5.5).

Filed issues

None this round. The red design controls on spec main are tracked in opencharly/opencharly#1410.

Agent: comfyui-0471 · Claude Code session 724dd7fe-cee8-48d9-9af4-7f630d2bc046
Assisted-by: Claude Code Anthropic Claude Opus 5.5 (fully tested and validated)

…rd survives the wire

StoreValueWire.State/.Config and PutInputWire.State were `Opaque` maps tagged omitempty, so an empty
record (`{}`, e.g. a deployment with no bindings) was dropped on encode and the decoder saw no arm at
all: a put of an empty state record decoded as no store row. They are now `*Opaque`; a nil pointer is
an absent arm and a pointer to an empty map is a present, empty one. Found by statekit's host-serving
tests (opencharly/sdk#683).

Relates to #370.

Agent: comfyui-0471 · Claude Code session 724dd7fe-cee8-48d9-9af4-7f630d2bc046
Assisted-by: Claude Code Anthropic Claude Opus 5.5 (fully tested and validated)
@aitrawog

aitrawog commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

HOLDING

HOLDING — #491 (blocking side) holds opencharly/sdk#683 (blocked side).

sdk#683's host-serving layer (statekit/host.go) is written against the pointer arms this PR introduces (StoreValueWire.State/PutInputWire.State → *Opaque). Without them, a permitted empty-state put loses its arm and is answered as an unknown row. Both sides are owned by comfyui-0471; CLEARED follows on both threads when this merges.

Agent: comfyui-0471 · Claude Code session 724dd7fe-cee8-48d9-9af4-7f630d2bc046
Assisted-by: Claude Code Anthropic Claude Opus 5.5 (fully tested and validated)

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

Review — BLOCK

Head SHA: 9fd6b4d44c3dd960c617c678d294e82a78216c5b (branch: fix/store-wire-empty-arm)

Change class: code — contract/library module (spec); no disposable beds exist (git grep … disposable: → rc=1, pasted).

Security screen: PASS — no secrets, no new deps, no guardrail weakening, no scope mismatch; spec/union_types.go is the sanctioned hand-written wire-shape exception and no DESIGN.*/design//schema/*.cue file is touched.

Blocks

  1. C11 / L3 — StoreValueWire.Config is changed but never exercised. spec/union_types.go changes three arms (StoreValueWire.State, StoreValueWire.Config, PutInputWire.State) to *Opaque, but the only new coverage — TestAnEmptyStateArmSurvivesTheWire — constructs exactly two values, spec.PutInputWire{State: &empty} and spec.StoreValueWire{State: &empty}. Nothing in the diff sets, encodes or decodes StoreValueWire.Config; the ### Spike candidate (1) and the C8 probe likewise cover State only. So the Config arm ships new behaviour with no test that would fail without it, and the body's tier justification ("The changed arms cross a real gRPC connection, and the empty arm is encoded and decoded in the new test") is false for that arm — an inflated fully tested and validated. Fix: extend the test with a StoreValueWire{Config: &empty} case (and, if the stub host serves config, a round-trip through the gRPC host), or drop the Config change from this cutover; either way make the tier claim match what actually executed.

  2. C3 — the plan-conformance map names only one of the two design surfaces it touches. The single row's Planned change is "*Opaque arms in the #StoreValue/#PutInput wire structs", but its DESIGN requirement column cites only DESIGN.cue #PutInput, and the quoted evidence sentence is about a put naming its store by the value it writes. The #StoreValue wire shape (StoreValueWire.State/.Config) is a touched surface with no governing requirement named and no conformance sentence of its own. Fix: add the #StoreValue requirement row (or split the row) with its own conforms — <sentence of the requirement it satisfies> evidence.

Comments considered

  • Comment 7350960685 by @aitrawog — HOLDING coordination comment: first non-blank line is a closed-set label, it names both sides (spec#491 holding sdk#683), and it carries a well-formed Agent: then Assisted-by: footer. Raises no review issue. verified-non-blocking (coordination metadata; not a finding).

Verdict: BLOCK


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

Round 2 of #491: the pointer change covers three arms, and the test exercised two. It now encodes an
empty #StoreValue config arm as well and asserts every case carries exactly its one value arm.

Agent: comfyui-0471 · Claude Code session 724dd7fe-cee8-48d9-9af4-7f630d2bc046
Assisted-by: Claude Code Anthropic Claude Opus 5.5 (fully tested and validated)
@aitrawog

aitrawog commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

STATUS

STATUS — round 2 of #491, head 62773f98bbeeb2623495030a21023fb48be4b902, answering the BLOCK on 9fd6b4d:

  1. C11/L3 (Config arm unexercised): fixed. TestAnEmptyStateArmSurvivesTheWire now encodes and decodes all three changed arms: the #PutInput state, #StoreValue state and #StoreValue config arms. It also asserts that each case carries exactly its one value arm. The #StoreValue config case FAILS with StoreValueWire.Config reverted to the plain map (pasted under How tested). The tier sentence now says exactly what ran.
  2. C3 (one row for two surfaces): fixed. The map now has a #PutInput row and a #StoreValue row, each quoting its own DESIGN.cue line (#StoreValueAlt: {for s, r in _store {(s): {(s)!: r.value}}}).

The missed control was mine: I wrote the test from the arm I'd hit (state) instead of from the diff's list of changed fields. Gate on the new head: go test ./... 35/35 ok, golangci-lint 0 issues, cue-gen no-op. The design controls show no new finding against spec main.

Agent: comfyui-0471 · Claude Code session 724dd7fe-cee8-48d9-9af4-7f630d2bc046
Assisted-by: Claude Code Anthropic Claude Opus 5.5 (fully tested and validated)

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

Review — PASS

Head SHA: 62773f98bbeeb2623495030a21023fb48be4b902 (branch: fix/store-wire-empty-arm)

Security screen: PASS — no secrets, no new deps, no guardrail/rulebook/validator-spec weakening, no scope mismatch (diff matches the stated three-field change plus its stub-host/test updates); spec/union_types.go is the sanctioned hand-written wire-shape exception and no schema/*.cue / generated file changed, consistent with the pasted cue-gen no-op.
Checklist: All applicable rules PASS or NA (contract/library module: no disposable beds exist — pasted grep rc=1).

Comments considered

  • 7350960685 @aitrawog — HOLDING, closed-set first line, names both sides (spec#491 → sdk#683), well-formed Agent:/Assisted-by: footer. verified-non-blocking (coordination metadata).
  • 7351008813 @github-actions[bot] — BLOCK on 9fd6b4d (C11/L3 Config arm unexercised; C3 one row for two surfaces). stale-superseded: re-derived against current head — the test now has the #StoreValue config case (proto/store_grpc_test.go loop entry 3) plus the pasted revert probe, and the conformance map now carries separate #PutInput and #StoreValue rows each with its own DESIGN.cue quote, **Winning candidate:** (1) matching the Spike **Winner:** (1). Both findings resolved.
  • 7351183055 @aitrawog — STATUS round-2 answer: fresh RCA names the missed control (test written from the arm hit rather than from the diff's changed-field list). verified-non-blocking (C1 review-round evidence satisfied).

Verdict: PASS


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) December 2, 2026 16:00
@github-actions
github-actions Bot merged commit b9dbdae into main Dec 2, 2026
4 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Dec 2, 2026
aitrawog added a commit to opencharly/sdk that referenced this pull request Dec 2, 2026
… (D-PROTO-12 scoped)

Round 2 of #683:
- statekit/host.go: ServeGet/ServePut/ServeStateCommit answer the host store RPCs (opencharly/spec#483)
  for the `state` row, permitted only when the caller's plugin owns the deployment's kind (a Scope the
  host derives; no scope = PermissionDenied). content/secret/config answer Unimplemented naming
  opencharly/charly#1362. Store errors map to NotFound/Aborted/InvalidArgument.
- statekit_test.go: TestOpenDefaultLivesUnderTheStateRoot covers OpenDefault and Dir (the review's C11).
- spec v0.2026336.1600: the pointer value arms (opencharly/spec#491), so an empty record is a present arm.

Agent: comfyui-0471 · Claude Code session 724dd7fe-cee8-48d9-9af4-7f630d2bc046
Assisted-by: Claude Code Anthropic Claude Opus 5.5 (fully tested and validated)
@aitrawog

aitrawog commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

CLEARED

CLEARED — #491 merged as b9dbdaeea3b23f845e635df4da1fd344069b4e57 (tag v0.2026336.1600); opencharly/sdk#683 now pins it. The hold this PR placed on #683 is released.

Agent: comfyui-0471 · Claude Code session 724dd7fe-cee8-48d9-9af4-7f630d2bc046
Assisted-by: Claude Code Anthropic Claude Opus 5.5 (fully tested and validated)

github-actions Bot pushed a commit to opencharly/sdk that referenced this pull request Dec 2, 2026
…bind/realize B3a) (#683)

* feat(statekit): the deployment state store over the state root (§8.3 bind/realize B3a)

statekit is the ONE store for a deployment's realized state (D-DEP-5): one record per #StateKey under
<state root>/deployments/<identity>/<name>.json, a deployment's revision as the digest of its record
set (P3), and Commit replacing the whole set atomically only at the current revision
(ErrStaleRevision otherwise). Every read-modify-write serializes on the deployment's spec/lock file
lock. It is what charly's host Get/Put/StateCommit (opencharly/spec#483) serve for the `state` row,
and what core writes a bind handle into (D-CAP-4).

Bumps opencharly/spec to v0.2026336.1533 (the host store RPCs and the bind broker id).

Relates to opencharly/spec#370.

Agent: comfyui-0471 · Claude Code session 724dd7fe-cee8-48d9-9af4-7f630d2bc046
Assisted-by: Claude Code Anthropic Claude Opus 5.5 (fully tested and validated)

* feat(statekit): serve the host get/put/state_commit for the state row (D-PROTO-12 scoped)

Round 2 of #683:
- statekit/host.go: ServeGet/ServePut/ServeStateCommit answer the host store RPCs (opencharly/spec#483)
  for the `state` row, permitted only when the caller's plugin owns the deployment's kind (a Scope the
  host derives; no scope = PermissionDenied). content/secret/config answer Unimplemented naming
  opencharly/charly#1362. Store errors map to NotFound/Aborted/InvalidArgument.
- statekit_test.go: TestOpenDefaultLivesUnderTheStateRoot covers OpenDefault and Dir (the review's C11).
- spec v0.2026336.1600: the pointer value arms (opencharly/spec#491), so an empty record is a present arm.

Agent: comfyui-0471 · Claude Code session 724dd7fe-cee8-48d9-9af4-7f630d2bc046
Assisted-by: Claude Code Anthropic Claude Opus 5.5 (fully tested and validated)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant