Read a plan entry's composed contributions and the consumer's address, so the client keeps reading plans once the seat carries what route-proxy serves its routes from (issue 774, research 072 row 34)

This commit is contained in:
2026-10-31 09:23:56 +01:00
parent 52c875f870
commit 252c8537c0
2 changed files with 18 additions and 4 deletions
@@ -108,6 +108,17 @@ type PlannedProvision struct {
// CredentialTool is, for a software-issued offer, the provider's tool the vault asks for the value (issue 928);
// the vault acts on it and this client only reads it.
CredentialTool string `json:"credential-tool,omitempty"`
// Given is what this module contributes to the provision, composed, and ConsumerAt where its machine is on the
// private network (issue 774): a provider serving from the plans alone (route-proxy) reads them; the client keeps
// them, so the plan reads whole.
Given []PlannedGiven `json:"given,omitempty"`
ConsumerAt string `json:"consumer-at,omitempty"`
}
// PlannedGiven is one contribution of the module to a provision, composed: its local name among several, and its values.
type PlannedGiven struct {
Local string `json:"local,omitempty"`
Values map[string]any `json:"values"`
}
// issuedForHolder is whether the entry names a value its provider's software issued for this holder alone (issue
@@ -9,8 +9,9 @@ import (
// A plan provision carries everything the controller's PlanProvision writes (issue 954): what the consumer
// contributes, where the provider is and who the consumer is at its end (issue 788), the names the mesh calls it
// (issue 792) and, for a software-issued offer, the tool the vault asks (issue 928). The client still refuses a field
// nobody writes.
// (issue 792), for a software-issued offer, the tool the vault asks (issue 928), and what the consumer contributes,
// composed, with where its machine is (issue 774: route-proxy serves its routes from them). The client still refuses a
// field nobody writes.
func TestAPlanProvisionWithEveryFieldTheControllerWritesIsRead(t *testing.T) {
p, err := json.Marshal(contributor(t, "shell:zsh:normal", "alias nox=mesh-cli"))
if err != nil {
@@ -18,7 +19,8 @@ func TestAPlanProvisionWithEveryFieldTheControllerWritesIsRead(t *testing.T) {
}
provision := `"provisions":[{"provision":"route","local":"web","provider":"novox","provider-module":"route-proxy",` +
`"credential-form":"pair","contributes":{"label":"git"},"at":"10.10.0.1","from":"novox","as":"gitea",` +
`"names":{"name-web":"git.example.org"}},{"name":"gitea-read","provision":"gitea-read","provider":"novox",` +
`"names":{"name-web":"git.example.org"},"given":[{"local":"web","values":{"name":"git.example.org","port":3000}}],` +
`"consumer-at":"10.10.0.2"},{"name":"gitea-read","provision":"gitea-read","provider":"novox",` +
`"provider-module":"gitea","credential-form":"issued","credential-tool":"gitea_agent_token",` +
`"path":"/var/lib/claude-code/gitea-read.secret"}],"items":`
value := fmt.Sprintf(`{"node":"g14","module":"mesh-cli","provisioning":%s}`,
@@ -29,7 +31,8 @@ func TestAPlanProvisionWithEveryFieldTheControllerWritesIsRead(t *testing.T) {
}
if len(got.Provisions) != 2 || got.Provisions[0].At != "10.10.0.1" || got.Provisions[0].From != "novox" ||
got.Provisions[0].As != "gitea" || got.Provisions[0].Names["name-web"] != "git.example.org" ||
got.Provisions[1].CredentialTool != "gitea_agent_token" {
got.Provisions[1].CredentialTool != "gitea_agent_token" || len(got.Provisions[0].Given) != 1 ||
got.Provisions[0].Given[0].Local != "web" || got.Provisions[0].ConsumerAt != "10.10.0.2" {
t.Fatalf("the plan's provisions read as %+v", got.Provisions)
}
spoilt := strings.Replace(value, `"at":`, `"surprise":1,"at":`, 1)