Skip to content

feat(schema)!: publish endpoints by name — #Publication, #PortRange, publication state (D-PUB) - #478

Merged
github-actions[bot] merged 3 commits into
mainfrom
feat/publish-endpoints
Dec 2, 2026
Merged

github-actions[bot] merged 3 commits into
mainfrom
feat/publish-endpoints

Conversation

@aitrawog

@aitrawog aitrawog commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The spec leg of D-PUB (DESIGN §17.1, opencharly/opencharly#1404, v2026.336.1240). A deployment publishes the endpoints its box provides by name. The box's ports are its endpoints; where a deployment publishes them is the deployment's. This removes the mixing of the two that the old port lists carried.

  • Shapes added:

    • #Publication (port: N | "auto", address defaulting to 127.0.0.1);
    • #PortRange;
    • #PublicationRecord (the realized {address, port, mode}, kept in state, never in a document, per D-DOC-4);
    • Deploy.publish;
    • Deploy.publication: the realized publications, ONE charly-written state record per deployment whatever its kind (a vm's ssh among them), beside resolved_image. It also rides the state patch (SaveDeployStateInput.publication) and the vm plugin's prepare input (LifecyclePrepareInput.publication, replacing its ssh_port);
    • DeployConfig.port_range: the local document's range derived and auto ports are leased from, typed #PortRange (to >= from, checked by CUE and by PortRange.Validate).

    The int | "auto" union is the hand type PublicationPort (spec/union_types.go), because gengotypes degrades that disjunction to any. The field is a *PublicationPort: nil is the derived form, so a derived publication is omitted when written back and an explicit null decodes as derived.

  • The box side: a box's ports are its provide: {endpoint: …} entries (D-CAP-8), carried by one ai.opencharly.endpoint label (BoxMetadata.Endpoint). The resolved candy model (CandyModel.Endpoint) and the resolved box views carry them as the named #Endpoint.

  • Tunnels: TunnelConfigFromMetadata(meta, published) resolves over the box's endpoints and the realized publications. A tunnel scope's ports name guest endpoint ports; each backend is the endpoint's published host port, and the scheme is the endpoint's protocol.

  • Deleted, a hard cutover:

    • #PortPin with its alias, and Deploy.port / resolved_port;
    • the candy and candymodel port: unions, together with PortSpec and the candy reader's Port() / PortSpecs() / HasPorts() (replaced by Endpoint());
    • the ai.opencharly.port and port_proto labels;
    • SaveDeployStateInput.ports / set_ports;
    • VM network.port_forwards and ssh.port / port_auto;
    • the VM ssh_port / port_forwards state, KubeVirt's ssh_port, and the vm prepare input's ssh_port.
  • Kept: firecracker's ssh_port is the guest's own port, reached over its TAP network, not a host publication. libvirt's #LibvirtInterface.port_forwards is the bound driver's own domain-definition shape (D-HW-5), into which a VM plugin renders publications.

  • Skills: the spec skills that documented the old shapes (layer, image, vm-spec, vms-catalog) now document the new ones.

Relates to opencharly/opencharly#1390 (D-PUB wave, spec leg). Consumers follow producer-first: sdk, charly core, charly migrate, the deploy and check plugins, then the content repos.

Files

File Status
.agents/skills/image/SKILL.md M
.agents/skills/layer/SKILL.md M
.agents/skills/vm-spec/SKILL.md M
.agents/skills/vms-catalog/SKILL.md M
container/box_metadata_coneb.go M
container/box_metadata_coneb_test.go M
schema/00_common.cue M
schema/box.cue M
schema/boxmetadata.cue M
schema/candy.cue M
schema/candymodel.cue M
schema/deploy.cue M
schema/hand_state_lockstep_test.go M
schema/port_range_test.go A
schema/resolvedproject.cue M
schema/seam.cue M
schema/vm.cue M
spec/candy_reader.go M
spec/cue_types_gen.go M
spec/deploy_config.go M
spec/hand_state_types.go M
spec/label_consts.go M
spec/port_mapping.go M
spec/scalar_aliases.go M
spec/tunnel_resolve.go M
spec/tunnel_resolve_test.go M
spec/union_types.go M

How tested

The change class is contract/schema (SDD). The gate is spec's regeneration plus the module tests on the committed tree, head 968a94300b8118fbcabcd3df1576af394f60ffec:

# head 968a94300b8118fbcabcd3df1576af394f60ffec (git rev-parse HEAD)
$ charly task cue-gen
  [pass] run — download and pin protoc + the two Go codegen plugins
  [pass] run — render the proto IDL from CUE and compile the Go stubs
  [pass] run — generate the Go params in-process + schemagen the vocab lists
  [pass] check — regen is reproducible — TestGenReproducible passes on the committed tree
$ gofmt -l .                                 (no output)
$ go build ./... && go vet ./...             (no output)
$ go test ./...                              (35 packages ok)
$ grep -rn -E 'PortPin|PortSpec\b|resolved_port|ResolvedPort|port_proto|PortProto|PortAuto|port_auto|PortForwards|HasPorts' --include=*.go --include=*.cue --include=*.md --include=*.yml . | grep -v 'CHANGELOG/' | grep -v 'LibvirtPortForward\|LibvirtInterface' | wc -l
0

Spike

RCA claim: the spec schema carries host ports in the box definition (candy port:, the port labels) and the deployment's realized ports in authored nodes (resolved_port). DESIGN D-PUB/D-DOC forbid both.

Candidates spiked: for the port: N | "auto" field:

  • (a) a plain int plus a separate auto: bool. Fails: it is a second spelling of one value, and DESIGN's #Publication has one field.
  • (b) the hand union PublicationPort (spec's existing union_types.go convention). Works: TestPublicationPort_Forms decodes 41235, auto and an absent port, refuses any, 70000 and 0, and round-trips JSON.

The regression tests fail on the unmodified tree (run in a throwaway detached worktree of origin/main carrying only the new test file):

$ go test ./spec -run 'TestTunnelConfigFromMetadata|TestPublicationPort'   (origin/main + the new tests)
# github.com/opencharly/spec/spec [github.com/opencharly/spec/spec.test]
spec/tunnel_resolve_test.go:11:61: undefined: PublicationRecord
spec/tunnel_resolve_test.go:15:3: unknown field Endpoint in struct literal of type BoxMetadata
spec/tunnel_resolve_test.go:21:20: undefined: PublicationRecord
spec/tunnel_resolve_test.go:31:40: too many arguments in call to TunnelConfigFromMetadata
	have (*BoxMetadata, map[string]invalid type)
	want (*BoxMetadata)
spec/tunnel_resolve_test.go:47:40: too many arguments in call to TunnelConfigFromMetadata

Review round 2 (the derived form). The first two verdicts found the derived form unproven: on head 4dd5b7da0042a612b341cf52ac88048dcf5a6034 a derived publication marshalled to "port":null, and that failed to decode. Probe on that head (throwaway worktree):

$ go test ./spec -run TestProbeDerivedRoundTripOldHead -v      (head 4dd5b7da0042a612b341cf52ac88048dcf5a6034, probe only)
    zz_probe_test.go:16: json={"publish":{"web":{"port":null,"address":"127.0.0.1"}}} unmarshal-err=publish port "": want a port number or `auto`
    zz_probe_test.go:17: yaml="publish:\n    web:\n        address: 127.0.0.1\n"
    zz_probe_test.go:19: derived publication does not round-trip through JSON: publish port "": want a port number or `auto`
--- FAIL: TestProbeDerivedRoundTripOldHead (0.00s)
FAIL
FAIL	github.com/opencharly/spec/spec	0.004s
FAIL

Candidates for the derived form: (b1) keep the value type and special-case null in both decoders. That decodes, but the derived form is still emitted as port: null, because a struct field is never omitted. (b2) a *PublicationPort with nil as derived, plus null-safe decoders. This works: the derived form is omitted, and an explicit null decodes as derived. The new tests on this head:

$ go test ./spec ./schema -run 'PublicationPort|PortRange|Tunnel' -v
--- PASS: TestTunnelConfigFromMetadata_ScopeNamesGuestPorts (0.00s)
--- PASS: TestTunnelConfigFromMetadata_UnpublishedEndpointSkipped (0.00s)
--- PASS: TestTunnelConfigFromMetadata_NoTunnel (0.00s)
--- PASS: TestPublicationPort_Forms (0.00s)
--- PASS: TestPublicationPort_DerivedRoundTrip (0.00s)
--- PASS: TestDeployConfigPortRange (0.00s)
ok  	github.com/opencharly/spec/spec	0.009s
--- PASS: TestPortRangeAndPublicationConstraints (0.04s)
ok  	github.com/opencharly/spec/schema	0.053s

Winner: (b), with (b2) for the derived form.

RCA verdict: confirmed: the new shapes compile, round-trip and reject the invalid forms; the old tree lacks them.

Rulebook compliance

Plan conformance

Winning candidate: (b), with (b2): the hand union *PublicationPort, nil = derived.

Planned change DESIGN requirement Disposition
Deploy.publish of #Publication D-PUB-1 conforms — "A publish entry names a provided endpoint and carries a #Publication: an optional port (a number or auto) and an address, 127.0.0.1 by default."
derived (nil) and auto port forms D-PUB-3 conforms — "An entry without a port takes one derived from the deployment's identity (D-NEST-4) within port_range, stable across realizations and recorded in state"
DeployConfig.port_range of #PortRange DESIGN.cue #Document conforms — "port_range?: #PortRange // where derived and auto ports are leased from (§17.1)"
#PublicationRecord as one per-deployment state record; resolved_port deleted D-DOC-4 conforms — "realized values — derived and auto ports, resolved images, leases — live in state (D-DEP-5) and are never written into a document."
box ports become provide.endpoint; the endpoint label D-CAP-8 conforms — "A check reaches a provided endpoint by its name (D-VERB-8), never by restating its address."
  • C0: I loaded the git-workflow, strict-policy, design and xdg skills and read spec's AGENTS.md before editing.
  • C1: no warning. Every in-module consumer of a deleted field is rewritten in this change. Round 2: both BLOCK findings are fixed in commit 968a94300b8118fbcabcd3df1576af394f60ffec. The missed control was the regression suite: it covered only the pinned and auto forms, so the derived form had no test. It now has a round-trip test in both encodings, and port_range is wired and tested at both its CUE and Go boundaries.
  • C2: see the Spike block above.
  • C3: see the map above.
  • C4: one publication shape replaces the deploy pin list, the VM forward list, and the ssh port and its auto flag. One state record per deployment replaces three per-substrate port fields. One endpoint label replaces two port labels.
  • C5: no workaround.
  • C6: every old shape and name in this module is deleted. The repo-wide sweep in How tested returns 0 live uses outside libvirt's own domain shape; CHANGELOG history is excluded.
  • C7: the module's skills document the new shapes.
  • C8: new tests fail on the unmodified tree (above) and pass here: the tunnel over endpoints and publications; the publication port forms, including the derived round trip, which fails on the previous head; and the port_range and #Publication constraints.
  • C9: N/A. There is no live-service boundary.
  • C10: N/A. A contract module, proven by its own tests.
  • C11: the module gate passes on the committed head. A contract module's own CI is its gate.
  • C12: git status was clean first. The work is on a session worktree off fresh origin/main, with no force-push and no hook bypass.

Change classification

  • Change class: contract/schema (spec).
  • Gate: charly task cue-gen + go test ./....
  • Tier: fully tested and validated.
  • Breaking change + rollback: every consumer that bumps to this spec must move off the deleted port shapes in the same bump. That means sdk, charly core, the deploy and check plugins, and any document authoring candy port: or VM port_forwards / ssh.port. charly migrate rewrites the documents in the plugin-migrate leg. Roll back by reverting this squash commit; no consumer has bumped yet.

Filed issues

None: no new finding.

https://claude.ai/code/session_01Tvdn3tjf8tKajCd43DwENP

Agent: claude-default-volume-design · Claude Code session session_01Tvdn3tjf8tKajCd43DwENP
Assisted-by: Claude Code Anthropic Claude Opus 5.5 (fully tested and validated)

…publication state (D-PUB)

A deployment publishes the endpoints its box provides by name (publish: {<endpoint>: {port: N|auto,
address}}); a box's ports are its provide.endpoint entries, carried by one ai.opencharly.endpoint
label; the realized host side is a publication state record. Deletes #PortPin, Deploy port and
resolved_port, the candy/candymodel port unions and PortSpec, the port and port_proto labels,
VmNetwork.port_forwards, ssh.port/port_auto, and the VM and KubeVirt ssh_port/port_forwards state.

Claude-Session: https://claude.ai/code/session_01Tvdn3tjf8tKajCd43DwENP
Agent: claude-default-volume-design · Claude Code session session_01Tvdn3tjf8tKajCd43DwENP
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: 81e4d1c58b9c581771ac95f885545ff7570efc18 (branch: feat/publish-endpoints)

Change class: contract/schema (SDD) — spec module; no runtime/bed gate applies.

Security screen: PASS — no secrets, network egress, guardrail weakening, or instruction-injection; not security machinery.

Blocks

  1. C8/C1 — PublicationPort derived form does not round-trip; the body's "round-trip" claim is false for it. spec/union_types.go (new PublicationPort block, MarshalJSON / MarshalYAML / UnmarshalJSON / set):

    • MarshalJSON returns []byte("null") for the derived (zero) value and MarshalYAML returns nil (→ null).
    • But UnmarshalJSON falls into set("") for null (json.Unmarshal(null, &s) yields "" with no error, then strconv.Atoi("") errors) → json.Unmarshal of a marshaled derived publication errors.
    • Compounding it: Publication.Port PublicationPort is a struct with omitempty, and Go's omitempty never omits struct-kind fields, so a derived publication is emitted as port: null in both YAML and JSON documents (rather than omitted as the CUE port? intends). TestPublicationPort_Forms only round-trips auto and 8080 — the derived/null path is uncovered, so the suite stays green over a broken path while the body asserts "compile, round-trip and reject the invalid forms."
    • Fix: treat null/null-node as the derived zero value in UnmarshalJSON/UnmarshalYAML, stop emitting null for derived (pointer field or explicit omission), and add a round-trip test covering the derived form in both JSON and YAML.
  2. C8 — #PortRange is unreferenced and unproven in this leg. schema/00_common.cue adds #PortRange, and the Plan-conformance map claims it "conforms" to D-PUB-3 "within port_range", but no field in the spec schema references #PortRange and no test exercises its constraints. The D-PUB-3 conformance the map asserts is therefore not demonstrated by this diff. Either wire/consume it here (or add a validation test) or state explicitly that the port_range field lives in a named consumer leg, so the row is evidenced rather than asserted.

Verdict: BLOCK


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

View action run

The resolved candy model the sdk reads carried the candy's port list; it now carries the candy's
provide.endpoint entries as the named #Endpoint the box view, the label and the publication
resolver share (D-CAP-8, D-PUB-1).

Claude-Session: https://claude.ai/code/session_01Tvdn3tjf8tKajCd43DwENP
Agent: claude-default-volume-design · Claude Code session session_01Tvdn3tjf8tKajCd43DwENP
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: 4dd5b7da0042a612b341cf52ac88048dcf5a6034 (branch: feat/publish-endpoints)

Change class: contract/schema (spec module, SDD). No runtime/bed gate applies.

Security screen: PASS — no secrets/egress/guardrail weakening/injection; the tunnel_resolve.go rewrite drops stderr diagnostics as part of a logic change, not a security guardrail.

Comment disposition

  • Comment 7346318182 (@github-actions[bot]) — verified-blocking on both findings. Re-derived against the CURRENT head 4dd5b7da; the second commit (4dd5b7da, "candy model mirrors endpoints as #Endpoint") touches CandyModel/boxmetadata, not union_types.go or the port_range wiring, so neither finding is fixed or rebutted on the thread.

Blocks

  1. C8/C1 — PublicationPort derived form breaks JSON round-trip; body's "round-trip" claim is false for it. spec/union_types.go (new PublicationPort block):

    • MarshalJSON returns []byte("null") for the derived (zero) value.
    • UnmarshalJSON on null: json.Unmarshal(null, &s) yields "" with no error, so it falls into p.set("") → strconv.Atoi("") errors. So marshaling a derived publication and unmarshaling it back fails.
    • Publication.Port is a non-pointer struct with json:"port,omitempty"; encoding/json does not omit struct-kind fields, so a derived publication is emitted as "port":null in JSON rather than omitted.
    • TestPublicationPort_Forms only round-trips auto and 8080; the derived/null path is uncovered, so the suite stays green over the broken path while the Spike asserts "compile, round-trip and reject the invalid forms."
    • Fix: treat null/null-node as the derived zero value in UnmarshalJSON (and UnmarshalYAML), stop emitting null for derived (pointer field or a custom Publication marshal), and add a derived-form round-trip test in both JSON and YAML.
  2. C3/C8 — #PortRange is unreferenced and unproven; the D-PUB-3 conformance row overclaims. schema/00_common.cue adds #PortRange, and the Plan-conformance map claims it "conforms" to D-PUB-3 "within port_range", but no field in this diff references #PortRange and no test exercises its constraints. The port_range field D-PUB-3 names does not exist in this leg. Either wire/consume it here (e.g. a Deploy.port_range field plus a validation test), or state explicitly that the port_range field and leasing live in the charly-core consumer leg and adjust the row's evidence accordingly — otherwise #PortRange is dead in this change and the D-PUB-3 row is asserted, not demonstrated.

  3. C1 — review-round evidence missing. The prior BLOCK's two findings are neither fixed in the current diff nor rebutted with evidence on the thread, and ## Filed issues is empty. The second commit does not address either finding.

Verdict: BLOCK


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

View action run

… document's; one publication record per deployment

Review round 2. A derived publication is a nil *PublicationPort, omitted when written back,
and an explicit null decodes as derived (the zero value used to marshal to null and fail to
decode). #PortRange gains to >= from and is wired as DeployConfig.port_range. The realized
publications are one record on the deployment node, for every kind, replacing the VM and
KubeVirt state copies and the vm plugin's ssh_port input. CandyReader.Endpoint replaces
HasPorts.

Claude-Session: https://claude.ai/code/session_01Tvdn3tjf8tKajCd43DwENP
Agent: claude-default-volume-design · Claude Code session session_01Tvdn3tjf8tKajCd43DwENP
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

Round 2: both findings from the two BLOCK verdicts are fixed in commit 968a943.

  1. The derived publication round-trip (C8/C1). Reproduced on head 4dd5b7d: it marshalled to "port":null, which then failed to decode with publish port "": want a port number or auto``. #Publication.port is now a `*PublicationPort` with nil as the derived form, so a derived port is omitted. Both decoders read an explicit `null` as derived. `TestPublicationPort_DerivedRoundTrip` covers JSON and YAML, including the explicit null.
  2. #PortRange was unreferenced (C3/C8). It is now wired as the local document's port_range (DeployConfig.PortRange, DESIGN.cue #Document), with to >= from. TestPortRangeAndPublicationConstraints checks it at the CUE boundary and TestDeployConfigPortRange at the Go boundary. The map row now quotes the DESIGN.cue field.
  3. Review-round evidence (C1). This comment, plus the body's Spike block: the old-head probe and the two derived-form candidates.

Missed control: the regression suite covered only the pinned and auto forms, so the derived (zero) form had no test. It now does.

Also in this commit: the realized publications are ONE per-deployment state record (Deploy.publication), replacing the VM and KubeVirt copies and the vm prepare input's ssh_port; and CandyReader.Endpoint() replaces HasPorts(). The body is updated and re-keyed to the new head.

Agent: claude-default-volume-design · Claude Code session session_01Tvdn3tjf8tKajCd43DwENP
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: 968a94300b8118fbcabcd3df1576af394f60ffec (branch: feat/publish-endpoints)

Security screen: PASS — no secrets/egress, no guardrail weakening, no instruction-injection; spec-schema only.
Checklist: All applicable rules PASS or NA (L1–L3, C0–C12; SDD regen source↔generated consistent).

Comments considered:

  • 7346318182 (@github-actions[bot], head 81e4d1c) — stale-superseded. Both findings (derived-form round-trip; #PortRange unreferenced) are fixed in the current diff: Publication.Port is now *PublicationPort (nil = derived, null-safe decoders, TestPublicationPort_DerivedRoundTrip covers JSON+YAML+explicit-null), and #PortRange is wired as DeployConfig.PortRange with TestPortRangeAndPublicationConstraints (CUE) + TestDeployConfigPortRange (Go).
  • 7346358465 (@github-actions[bot], head 4dd5b7da) — stale-superseded. Same two findings plus review-round evidence; all addressed in commit 968a943 and the STATUS comment/body C1 (missed control named).
  • 7346516203 (@aitrawog) — verified-non-blocking. Maintainer STATUS; each claimed fix re-derived against the current diff and confirmed present.

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 13:18
@github-actions
github-actions Bot merged commit 7c74a82 into main Dec 2, 2026
4 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Dec 2, 2026
This was referenced Dec 2, 2026
aitrawog added a commit that referenced this pull request Dec 2, 2026
Brings in CHANGELOG/0.2026336.1318.md (#478's tag-on-merge entry); no code change.

Claude-Session: https://claude.ai/code/session_01Tvdn3tjf8tKajCd43DwENP
Agent: claude-default-volume-design · Claude Code session session_01Tvdn3tjf8tKajCd43DwENP
Assisted-by: Claude Code Anthropic Claude Opus 5.5 (fully tested and validated)
github-actions Bot pushed a commit that referenced this pull request Dec 2, 2026
…verrides (#479)

SaveDeployStateInput gains publish (D-PUB-1), the authored publication overrides a bed or CLI
persists onto the per-host entry like volume and env; #478 deleted the ports/set_ports pair it
replaces and left the realized side (publication) only.

Claude-Session: https://claude.ai/code/session_01Tvdn3tjf8tKajCd43DwENP
Agent: claude-default-volume-design · Claude Code session session_01Tvdn3tjf8tKajCd43DwENP
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