Skip to content
kazma.
Search Kazma Documentation & Site
ع

Multi-replica & SaaS residual hardening

Kazma’s default profile remains single-operator / single-node. The work below closes residual gaps for multi-user and multi-replica where the architecture allows — it does not claim full multi-tenant SaaS.

After a human approves a danger tool, the host is still powerful by design. Hardening (2026-07 residual batch):

ControlBehavior
Allowlist binariesNo interpreters; prod drops ps/kazma
Archive toolstar/zip off in production strict mode unless KAZMA_SHELL_ALLOW_ARCHIVE=1
Restricted PATHKAZMA_SHELL_STRICT defaults on in production — system/build dirs only
Binary resolveshutil.which under restricted PATH; no /tmp/evil/git
Scrubbed envNo parent API keys
Git denylistpush/force/credential/reset/rebase/clean -fd blocked
Workspace pathsAbsolute args must stay inside workspace root
Docker code_execForce in production / KAZMA_CODE_EXEC_DOCKER=force

Not removed: approved shell_exec / file_write / python_exec still mutate the host for the trusted operator. Treat YOLO and long HITL grants as elevated.

LayerMulti-replica status
Job claim/leaseYes on Postgres (documents/jobs_pg.py) on a Postgres install (KAZMA_DB_BACKEND=postgres or a postgresql:// KAZMA_DATABASE_URL), unless KAZMA_DOCUMENTS_JOBS_BACKEND=sqlite
Intake admissionYes with the Postgres job queue: durable reservations, an intake lease and a takeover fence, so a stalled replica’s intake is taken over and can never publish (documents/admission.py)
Metadata CRUDYes when KAZMA_DOCUMENTS_METADATA_BACKEND=postgres, or auto/unset on a Postgres install (repository_pg.py); the tenant storage quota is enforced in the publishing transaction
Content blobsShared filesystem/volume on documents.storage_root required
Upload spool slotsPer process (documents.capacity.max_concurrent_uploads)
GCBackend-agnostic — retention._mark dispatches to repository.gc_mark on both SQLite and Postgres

These are capabilities of the document backends, not a qualified deployment: scripts/certify_documents.py reports postgres_multi_replica and metadata_multi_replica as NOT RUN, and the runtime as a whole keeps one active owner (below). Always check GET /api/documents/ops/readiness. See Document processing ops and Document Intelligence.

LayerStatus
Tenant ContextVartenant_context + middleware
Client X-Tenant-IDIgnored when production or multi-user; JWT / principal only
Opaque sessionsForced when multi-user
Document ACLPer-tenant document + principal ACL on repository
Vault secretsTenant column + ContextVar filter
Vector memoryMetadata tenant_id filter on query
Swarm tasksmetadata.tenant_id stamped on dispatch
Knowledge / cron / MCPStill largely global (not per-tenant productized)

Env: KAZMA_MULTI_USER=1, KAZMA_PRODUCTION=1, KAZMA_DATABASE_URL, KAZMA_VAULT_KEY, KAZMA_JWT_SECRET (if JWT tenancy).

StateWasNow
HITL bus approvalsIn-process Event onlyConfigStore dual-write via swarm/shared_approvals.py + local Event
Swarm task resultsTaskStore (SQLite/PG)Unchanged — use Postgres for multi-node
Task list tenancyGlobalAuto metadata.tenant_id filter when multi-user/prod
Circuit breakersProcess memoryShared via ConfigStore when multi-user/prod (KAZMA_SHARED_BREAKERS)
MCP servers (user-added)Global ConfigStoreTenant-scoped key tenant.<id>.mcp.servers
Cron job listGlobaltenant_id column; UI list filtered
_active_tasksProcess memoryStill process-local; persist via TaskStore for history
KB crawl jobsProcess + ConfigStoreThe crawl journal (web_acquire/crawl_jobs.py): one row per job, owners scoped to this install
Knowledge librariesGlobalOwn knowledge.db; refused on an install with platform users (single-operator)
Swarm bus adaptersProcess singletonFan-out multi-platform; still one process
Browser affinityNoneCookie kazma-replica (KAZMA_REPLICA_ID, LB sticky)

These shared subsystems do not make the whole runtime safe for concurrent active replicas. The supported HA preparation profile has one active owner, a dedicated Postgres ownership session and a complete fenced state volume. Sticky routing or networked SQLite storage cannot replace ownership and fencing. See Multi-Region & HA for setup and qualification drills.

ModeBehavior
Production or multi-userNo host-local python_exec — Docker required
KAZMA_CODE_EXEC_DOCKER=forceSame
Lab escapeKAZMA_CODE_EXEC_ALLOW_LOCAL=1 (not recommended)
FeatureTelegramDiscordSlack
Text chatFullFullFull
Typing indicatorFullYesYes
Voice STT/TTSDeep pathSame depth via voice_helpers + discord_stt / slack_stt
Graph HITL buttonstelegram_keyboardsdiscord_keyboardsslack_blocks
Swarm HITL buttonsInline keyboardComponents v2Block Kit
Shared callback IDsplatform_callbackssame schemessame schemes
Modular parse/sendtelegram_parse/senddiscord_parse/sendslack_parse/send
Shared multi-replica approvalsYesYesYes
Message reactionssetMessageReactionset_reaction APIset_reaction API

Layout (2026-07 UX modules):

adapters/
platform_callbacks.py # hitl: / swarm_ / model_ schemes
platform_keyboards.py # Discord components + Slack blocks
telegram_{keyboards,callbacks,parse,send,stt}.py
discord_{keyboards,callbacks,parse,send}.py
slack_{blocks,callbacks,parse,send}.py
voice_helpers.py