Skip to content

feat(tenancy): open multi-tenant startup only in a kye2e test build - #744

Open
Yoshiofthewire wants to merge 2 commits into
mainfrom
feat/kye2e-gate
Open

Yoshiofthewire wants to merge 2 commits into
mainfrom
feat/kye2e-gate

Conversation

@Yoshiofthewire

Copy link
Copy Markdown
Member

In one line: Only a binary built with -tags kye2e (the suite end-to-end run) passes KyPost's multi-tenant startup refusal; every release build and image still refuses, and CI now proves it.

What changed

  • config.MultiTenantBuild is a constant from two build-tagged files: false in every release build, true only under -tags kye2e. No environment value, flag or -ldflags -X can set it.
  • CheckEnv refuses multi unless that constant is set. BootstrapAdmin returns nil (writes nothing) for multi in the test build, since K6 has no bootstrap administrator. The backup commands refuse multi in every build.
  • The test build only saves, discovers or loads an https issuer under .test. A stored real issuer reads as unconfigured.
  • scripts/check-test-build-tag.sh (in ci-backend-checks) keeps the tag inside the gate files and keeps -tags/GOFLAGS out of the Dockerfile, Makefiles, compose files and release workflows. It also runs the tagged tests.
  • scripts/check-release-image.sh fails on -tags=kye2e in go version -m. It also starts the image twice with a multi-tenant environment (through the entrypoint and as --mode server) and expects the release refusal. It runs in ci-docker, and in publish-main.yml and release-image.yml on a local build before the push. release-image.yml runs it again on the pushed digest.

Review this

  • backend/internal/sso/sso.go: the .test issuer check in loadUnlocked and ValidateIssuerURL. KyPost's issuer is runtime config (sso.json), not startup config, so the refusal lives here rather than at startup. That is a deliberate deviation from the design's "refuses to start".
  • .github/workflows/release-image.yml and publish-main.yml: a new local build plus check before the push. The push step reuses the gha cache.
  • scripts/check-release-image.sh: runs with no database (--network none, no KYPOST_DATABASE_URL), because dbbackend.Check connects before any command. It matches the gate's own message, so no other refusal can pass for it.

Checked

  • 13/13 mutations killed:
    • kye2e const false
    • each sso check removed
    • bootstrap nil dropped
    • backup lifted in the test build
    • .test suffix check
    • release const true (untagged tests and source check)
    • CheckEnv gate removed
    • bootstrap refusal removed
    • tag in the Dockerfile
    • -tags in the Dockerfile
    • tag in another Go file
  • Release check against real images built on Major (Ollama off):
    • the release image passes;
    • the kye2e image fails on its tag;
    • with the tag check mutated out, it fails because the image starts instead of refusing, through both the entrypoint and --mode server.
  • scripts/check-test-build-tag.sh, gofmt, golangci-lint (untagged and --build-tags kye2e), deadcode, shellcheck and check-publish-main.py are clean.
  • SQLite go vet ./... and go test -race ./...: all pass on the K host except packages needing files outside backend/, which kjob does not copy, and api, which hit the 10 m default timeout. Those are rerun in place on Major (see the comment below for the result).

Not checked: PostgreSQL. The change touches no store and the constant is false in every PostgreSQL run; CI's PostgreSQL legs run it. The publish workflows' new steps run only on a real publish.

You need to: nothing. Merge as usual. KyCalendar's e2e design row for KyPost can then say "gate built".

Detail
  • Design: KyCalendar docs/superpowers/specs/2026-11-24-multi-tenant-e2e-design.md, Mechanism and the KyPost row. Reference PRs: KyCalendar chore(deps): bump pinned Ollama to 0.34.3 #220, KyMessages-Native fix: close seven hostile-review findings, chiefly the bypassable KDF ceiling #52.
  • As built: tenancy spec, "The kye2e gate as built (2026-11-25)"; root and scripts/AGENTS.md; CHANGELOG.
  • Untagged tests: TestCheckEnvRefusesMulti, TestBootstrapAdminRefusesMulti (new, also asserts nothing is written), TestCheckTestIssuer (new). Tagged: TestE2EBuildOpensMulti, TestE2EBuildBootstrapsNothingAndKeepsBackupsRefused, TestE2EBuildRefusesARealIssuer.
  • A kye2e image with a full multi env, started on Major, got past bootstrap and then failed at the next K2 requirement ("table-mode documents require PostgreSQL"): the tag lifts only the gate.

🤖 Generated with Claude Code

config.MultiTenantBuild comes from two build-tagged files: false in every
release build, true only under -tags kye2e, the suite end-to-end run
(KyCalendar multi-tenant e2e design, KyPost row). CheckEnv refuses multi
unless it is set; BootstrapAdmin returns nil in that build (K6: no
bootstrap administrator) and the backup commands keep refusing. The test
build saves, discovers and loads only an https issuer under .test.

scripts/check-test-build-tag.sh keeps the tag in the gate files and build
tags out of every release path; scripts/check-release-image.sh fails on
-tags=kye2e in the binary's build info or an image that starts in multi
mode. Both run in CI, and the release check runs in publish-main.yml and
release-image.yml before anything is pushed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Yoshiofthewire

Yoshiofthewire commented Nov 26, 2026 •

Copy link
Copy Markdown
Member Author

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪

🧪 PR contains tests

⚡ Recommended focus areas for review

Tagged-test failure

This release-only assertion also runs with -tags kye2e, where BootstrapAdmin() intentionally returns nil, so a full tagged test run fails. TestCheckEnvRefusesMulti likewise conflicts with the tagged behavior. The new script hides these failures by selecting only TestE2EBuild*. Skip release-only assertions when config.MultiTenantBuild is true, or move them into release-tagged test files, so the complete tagged suite remains runnable.


Advisory only: this comment never gates the pull request.
gpt-6.1-sol using pr-agent on behalf of Yoshi

@Yoshiofthewire

Yoshiofthewire commented Nov 26, 2026 •

Copy link
Copy Markdown
Member Author

Security review - cleared

Detail withheld: this repository is public, and posting an unfixed finding here would be public disclosure. The full report was posted to the hand-off board at https://myslop.urlxl.us/f/pr-reviewer-busnes-app-kypost-server-744, where it is readable by the operator and expires seven days after the last post.


gpt-6.1-sol using security-audit on behalf of Yoshi

@Yoshiofthewire

Yoshiofthewire commented Nov 26, 2026 •

Copy link
Copy Markdown
Member Author

Autonomous review - 1/1 personas cleared

  • security: cleared

Merging remains a human decision; this bot never approves.


gpt-6.1-sol using security-audit on behalf of Yoshi

@Yoshiofthewire

Yoshiofthewire commented Nov 26, 2026 •

Copy link
Copy Markdown
Member Author

Note

🤖 Claude Opus 5.5 responding on behalf of Yoshiofthewire

Verification at head 18bdb95: the five packages kjob could not run (files outside backend/, and api past the 10 m default) passed in place on Major with go test -race -count=1 -timeout 60m -p 2: api 794 s, app 201 s, cryptutil, ingress, pgpmail/pgpmailtest. Every other package passed go vet ./... and go test -race ./... on the K host earlier. ci-docker, which runs the new release-image check, is green.

The Dockerfile builds ./cmd/main.go as a file, so go version -m lists the
module as dep; a package build lists it as mod. Accept either.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Yoshiofthewire

Copy link
Copy Markdown
Member Author

Note

🤖 Claude Opus 5.5 responding on behalf of Yoshiofthewire

On the Guide's "Build-info mismatch" (#744 (comment)): the check matched the real image, but it now accepts both forms anyway, at 168074f.

  • Verified: the Dockerfile runs go build ./cmd/main.go (a file), so go version -m prints path command-line-arguments and the module as a dep record. A local release image passed the check, and ci-docker passed at 18bdb95.
  • A package build (go build ./cmd/) prints it as mod. The check now matches ^\t(mod|dep)\tgithub.com/Busnes-app/kypost-server/backend\t, so a future Dockerfile change cannot trip it.
  • Re-run at 168074f: the release image passes, and the kye2e image fails on its tag.

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