mirror of
https://github.com/hanzoai/cloud.git
synced 2026-11-17 16:36:24 +00:00
`go build ./cmd/cloud` failed on a fresh clone: the feature-flag evaluator linked a Rust staticlib nobody had built, and there were no make targets at all. The evaluator moves behind `-tags flags_native`, because cgo is on by default and already links C — only an explicit tag can mean "the Rust archive exists". Cold build now takes 37s and needs nothing but Go. The encryption refusal contradicted itself. It offered "or run a pure-Go dev build" as the way out while running ON one, having just logged that encryption was off. Both statements came from a time when !cgo meant "cannot encrypt"; hanzoai/sqlite reports EncryptionAvailable() == true under both build tags now, so the pure-Go build is exactly as capable and exactly as refusing. The route is deleted, not the refusal — a build that CAN encrypt and has no key must keep failing closed. `make dev` mints a real key instead of an exemption, so the laptop runs the production path. Three local apps, every route a typed op: base (documents), tasks (a durable queue with atomic lease/ack), functions (registry + runner, STAGED because it executes code). No kv and no sql — base is already both, and two more doors onto one room would be two more names to keep in agreement. Typed ops are the reason /mcp answers at all. zip projects its op registry into MCP, the schema'd OpenAPI document and the call plane, but it does that from Listen, which runs after the console catch-all is registered — so the endpoint existed and still 404'd. Prepare() moves ahead of the catch-all. 19 MCP tools and 22 JSON schemas where there were none, because there were zero typed ops in this tree before. Plugins build on first request instead of at boot. The manifest is still validated at boot — a typo must not wait for traffic — but a plugin whose source is missing no longer takes the whole binary down with it. The console is embedded and served at /, through a serveFS that takes an fs.FS so the serving code stays single. A /v1 miss is still JSON: a client expecting JSON never receives an HTML shell. PORT is read when CLOUD_LISTEN says nothing. It was the first thing everyone tried and the one thing that did nothing. .githooks/pre-push refuses any push to origin carrying commits or imports from the private edition. It treats every refs/remotes namespace that is not origin as private, which catches forgeall/* and incx/* — leftovers from removed remotes holding thousands of private commits that an enumerated list misses.
62 lines
1.9 KiB
Go
62 lines
1.9 KiB
Go
package cek
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
// The dev opt-out has exactly one job: relax the NO-KEY case on a capable build,
|
|
// and only when asked explicitly. These cases pin the boundary, because the
|
|
// failure mode of getting it wrong is a production binary that silently writes
|
|
// plaintext — the thing the whole package exists to prevent.
|
|
func TestDevUnencrypted_OnlyExplicitTruthyValuesCount(t *testing.T) {
|
|
cases := []struct {
|
|
val string
|
|
want bool
|
|
}{
|
|
{"1", true},
|
|
{"true", true},
|
|
{"TRUE", true},
|
|
{"yes", true},
|
|
{"on", true},
|
|
{" 1 ", true}, // trimmed — a trailing newline from a shell export still counts
|
|
|
|
// Everything else is OFF. "0" and "" matter most: an empty export
|
|
// inherited from a parent shell, or a deliberate disable, must never be
|
|
// read as consent to drop encryption.
|
|
{"", false},
|
|
{"0", false},
|
|
{"false", false},
|
|
{"no", false},
|
|
{"off", false},
|
|
{"maybe", false},
|
|
{"2", false},
|
|
}
|
|
for _, tc := range cases {
|
|
t.Run("val="+tc.val, func(t *testing.T) {
|
|
t.Setenv(DevUnencryptedEnv, tc.val)
|
|
if got := devUnencrypted(); got != tc.want {
|
|
t.Fatalf("devUnencrypted() with %q = %v, want %v", tc.val, got, tc.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
// Absent entirely is not opted in. Separate from the empty-string case above:
|
|
// unset and set-to-empty reach different branches of os.Getenv.
|
|
func TestDevUnencrypted_UnsetIsOff(t *testing.T) {
|
|
os.Unsetenv(DevUnencryptedEnv)
|
|
if devUnencrypted() {
|
|
t.Fatal("devUnencrypted() = true with the variable unset; the default must be OFF")
|
|
}
|
|
}
|
|
|
|
// The two variables must stay distinct. Overloading one to mean both "here is
|
|
// the key" and "run unencrypted" is how a deployment goes plaintext because
|
|
// someone put the wrong value in a secret.
|
|
func TestDevUnencrypted_IsNotTheMasterKeyVariable(t *testing.T) {
|
|
if DevUnencryptedEnv == MasterKeyEnv {
|
|
t.Fatalf("the dev opt-out and the master key must be different variables; both are %q", MasterKeyEnv)
|
|
}
|
|
}
|