oficina / fichas Public

Read FICHAS_SUITE_CONSUMERS at boot; depend on the suite module at 53b79d5

server.ConsumersFromEnv(getenv, "fichas") inside LoadConfig: unset is no
consumers, malformed refuses boot (spec §6.5). go get resolved
amadan.net/oficina/suite@53b79d5 directly, no replace. The suite module
joins estilo in the Makefile's GOPRIVATE so the public proxy and checksum
database are never asked about it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 80369214d6e3c05bf768cbf91a935b682bc8b34e parent ea3a491
5 files changed, +46 −1
  • Makefile +3 −1
  • go.mod +1 −0
  • go.sum +2 −0
  • internal/fichas/config.go +10 −0
  • internal/fichas/config_test.go +30 −0
diff --git a/Makefile b/Makefile
index 4273383..c61dad7 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,10 @@
APP := fichas
# estilo, the suite's design module, is private: fetch it with Git auth.
+# So is the suite contract module (spec §6): never ask the public proxy or
+# checksum database about it.
private_comma := ,
-export GOPRIVATE := $(if $(GOPRIVATE),$(GOPRIVATE)$(private_comma))amadan.net/oficina/estilo.git
+export GOPRIVATE := $(if $(GOPRIVATE),$(GOPRIVATE)$(private_comma))amadan.net/oficina/estilo.git,amadan.net/oficina/suite
# What `carlos ship -target` defaults to, and therefore what a release
# must be built for. Building for your own machine and shipping that is a
diff --git a/go.mod b/go.mod
index e49ebea..f6469dd 100644
--- a/go.mod
+++ b/go.mod
@@ -6,6 +6,7 @@ toolchain go1.26.5
require (
amadan.net/oficina/estilo.git v0.0.0-20261001113457-a264aa5b9540
+ amadan.net/oficina/suite v0.0.0-20261101214529-53b79d50971f
amadan.net/rastrillo/rastrillo v0.26.1-0.20260908075707-29e4491631bd
github.com/chromedp/cdproto v0.0.0-20250724212937-08a3db8b4327
github.com/chromedp/chromedp v0.14.2
diff --git a/go.sum b/go.sum
index cf6c1dc..57e23a9 100644
--- a/go.sum
+++ b/go.sum
@@ -1,5 +1,7 @@
amadan.net/oficina/estilo.git v0.0.0-20261001113457-a264aa5b9540 h1:lG6hyBqz13XGisiyhKMHzPoBK6QP8weHQ02je/2gquk=
amadan.net/oficina/estilo.git v0.0.0-20261001113457-a264aa5b9540/go.mod h1:4u0jNBtIdMLOsJyrScfqoEuYDJF7BBM3qM9YWbzt6aw=
+amadan.net/oficina/suite v0.0.0-20261101214529-53b79d50971f h1:weOUYorsrOCUwYvuBGTf/Bvfyi4f1CL2aTeoeKQYC3g=
+amadan.net/oficina/suite v0.0.0-20261101214529-53b79d50971f/go.mod h1:Xgw0N+DBiDzkhQHm/nIhgumfaiMElDg/KIFD1OxTm5w=
amadan.net/rastrillo/rastrillo v0.26.1-0.20260908075707-29e4491631bd h1:jlFSt95M1ontOg+VePU+kIJpChtWqDQAbnmlxqCnbgc=
amadan.net/rastrillo/rastrillo v0.26.1-0.20260908075707-29e4491631bd/go.mod h1:RpyHVPD0udcSfHJroY0KZE/FUjgw6Tvfo8SJm2qeZGE=
github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
diff --git a/internal/fichas/config.go b/internal/fichas/config.go
index a2c1717..df39fbe 100644
--- a/internal/fichas/config.go
+++ b/internal/fichas/config.go
@@ -10,6 +10,7 @@ import (
"strings"
"amadan.net/oficina/fichas/internal/fichas/seal"
+ "amadan.net/oficina/suite/server"
)
// Config is everything fichas needs from platform config.
@@ -51,6 +52,10 @@ type Config struct {
// name Home and the other apps use), the account menu's "All apps".
// Empty — a standalone instance — and there is no "All apps".
Directory string
+ // SuiteConsumers are the siblings allowed to call the suite routes
+ // (spec §6.5), from FICHAS_SUITE_CONSUMERS. None, and the routes do
+ // not exist.
+ SuiteConsumers []server.Consumer
}
// ErrMissing is returned when required platform config is absent.
@@ -148,6 +153,11 @@ func LoadConfig(getenv func(string) string) (Config, error) {
default:
return Config{}, fmt.Errorf("fichas: FICHAS_SHAPE is %q; it is %q or %q", c.Shape, ShapeLone, ShapeSuite)
}
+ // Parsed at boot: a malformed list refuses to start rather than
+ // silently serving nobody, or serving somebody it should not.
+ if c.SuiteConsumers, err = server.ConsumersFromEnv(getenv, "fichas"); err != nil {
+ return Config{}, fmt.Errorf("fichas: FICHAS_SUITE_CONSUMERS: %w", err)
+ }
c.ContractRelease, err = loadContractRelease(getenv, c.Origin)
if err != nil {
return Config{}, err
diff --git a/internal/fichas/config_test.go b/internal/fichas/config_test.go
index 2f2e1ec..b97ee3c 100644
--- a/internal/fichas/config_test.go
+++ b/internal/fichas/config_test.go
@@ -4,6 +4,8 @@ import (
"encoding/base64"
"errors"
"testing"
+
+ "amadan.net/oficina/suite/server"
)
func env(m map[string]string) func(string) string {
@@ -233,3 +235,31 @@ func TestLoadConfigTakesTheDirectoryOrigin(t *testing.T) {
}
}
}
+
+// FICHAS_SUITE_CONSUMERS (spec §6.5): unset is no consumers; a good list is
+// read; anything malformed refuses boot rather than silently serving
+// nobody.
+//
+// MUTATION-TESTED 2026-11-01, reverted: the ConsumersFromEnv error
+// discarded (boot continues with no consumers) → "malformed".
+func TestSuiteConsumersAreReadAtBoot(t *testing.T) {
+ c, err := LoadConfig(env(map[string]string{}))
+ if err != nil || c.SuiteConsumers != nil {
+ t.Fatalf("unset: %+v, %v", c.SuiteConsumers, err)
+ }
+ good := `[{"consumer_id":"memoria","tokens":[{"epoch":1,"sha256":"` + server.TokenHash("t") + `"}]}]`
+ c, err = LoadConfig(env(map[string]string{"FICHAS_SUITE_CONSUMERS": good}))
+ if err != nil || len(c.SuiteConsumers) != 1 || c.SuiteConsumers[0].ID != "memoria" {
+ t.Fatalf("good: %+v, %v", c.SuiteConsumers, err)
+ }
+ for name, bad := range map[string]string{
+ "not JSON": "memoria:abc",
+ "a plaintext token": `[{"consumer_id":"memoria","tokens":[{"epoch":1,"sha256":"the-token"}]}]`,
+ "no tokens": `[{"consumer_id":"memoria","tokens":[]}]`,
+ "an unknown field": `[{"consumer_id":"memoria","origin":"x","tokens":[{"epoch":1,"sha256":"` + server.TokenHash("t") + `"}]}]`,
+ } {
+ if _, err := LoadConfig(env(map[string]string{"FICHAS_SUITE_CONSUMERS": bad})); err == nil {
+ t.Errorf("malformed (%s) was accepted", name)
+ }
+ }
+}