Skip to content

feat(engine): add a development mode and quiet transient start-up errors - #12

Closed
hasithaa wants to merge 21 commits into
runtime/packagingfrom
runtime/dev-mode
Closed

hasithaa wants to merge 21 commits into
runtime/packagingfrom
runtime/dev-mode

Conversation

@hasithaa

@hasithaa hasithaa commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Purpose

Resolves wso2/product-integrator#2919

Replaces #8, reopened from a wso2 branch so the PRs form a GitHub stack; its review history stays on #8.

Developers need the runtime on their own machine without a database server, TLS or an identity provider, like temporal server start-dev. And a healthy start logged hundreds of transient errors (about 400 on a fresh PostgreSQL start), which makes it look broken.

Goals

  • workflow-engine start-dev and bin/workflow-runtime dev: every service on SQLite (in memory, or --db-file), no authorization, on 127.0.0.1:7233, with default and each --namespace created before the services start.
  • A start-up grace period: for two minutes, errors from services joining the membership ring and acquiring shards are logged at debug level.
  • Membership ports above 32767 are refused on PostgreSQL and MySQL.

Approach

  • Namespaces before start. Dev mode registers its namespaces with Temporal's schema/sqlite.CreateNamespaces, on a database connection held open for the process (SQLite deletes an in-memory database with its last connection).

  • WorkflowKind pre-registered. The namespaces carry the WorkflowKind search attribute. ballerina/workflow registers it at start and then starts a workflow, which the frontend refused until its namespace cache refreshed. That reproduced on every fresh development engine, and is fixed by setting the column alias when the namespace is created.

  • Grace-period logger. quietLogger wraps the engine's logger and matches the error tag's text against known transient causes, during the grace period only:

    • Not enough hosts to serve the request
    • shard status unknown
    • context canceled
    • the first-start cluster metadata race
    • Frontend is not healthy yet

    No new dependency is needed: zap is not in the WSO2 registry, so the logger uses Temporal's tag API.

  • Membership ports. Temporal's PostgreSQL and MySQL schemas store the membership port in a SMALLINT, so a service port above 33067 broke membership at start. Found by testing on high ports.

Release note

bin/workflow-runtime dev starts a development Workflow Runtime with the default namespace and no setup; transient start-up errors no longer flood the log.

Documentation

docs/user-guide/quick-start.md (new); install, configure, connect, monitor, troubleshoot and the reference updated; docs/features/engine.md, docs/features/runtime-config.md, the zip README.

Automation tests

  • Unit tests:
    • start-dev flags, the namespaces created before the server, and errors.
    • Real SQLite namespace creation, in memory and in a file, run twice.
    • The grace-period logger, before and after the window.
    • The membership port rule, and the dev script command.
  • Manual:
    • A ballerina/workflow integration ran its first workflow on a fresh in-memory development engine.
    • A --db-file engine kept its namespaces and workflows across a restart.
    • Error lines dropped from about 400 to 0 on a fresh PostgreSQL first start with 512 shards, and from about 20 to 0 on development starts.

Security checks

  • Followed secure coding standards: yes. Development mode listens on 127.0.0.1 by default and says it has no authorization.
  • Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets: yes

Related PRs

#4, #5, #6, #7 (base).

Test environment

Go 1.26.10, macOS arm64; PostgreSQL 16 in Docker; Ballerina 2201.14.1 with ballerina/workflow 1.0.2.

Summary by CodeRabbit

  • New Features
    • Added a runtime launcher with commands for starting the engine, running in development mode, displaying the version, and rendering configuration.
    • Added configuration options for runtime profiles, database connections, TLS, JWT authentication, and Prometheus metrics.
    • PostgreSQL and MySQL schemas can be prepared automatically at startup.
    • Added ZIP distributions and multi-architecture container images, with examples for Docker Compose and systemd.
  • Documentation
    • Added user guides for installation, configuration, security, databases, deployment, monitoring, scaling, and troubleshooting.
  • Bug Fixes
    • Configuration rendering hides database passwords.

workflow-engine start-dev (workflow-runtime dev) runs every service on SQLite, in memory or in a --db-file,
with no authorization on 127.0.0.1, and creates "default" and each --namespace before the services start, like
temporal server start-dev. The namespaces carry the WorkflowKind search attribute: when ballerina/workflow
registers it at start, its first workflow is refused until the namespace cache refreshes. The in-memory database
is held open for the process, since SQLite deletes it with its last connection.

For two minutes after start, errors Temporal logs while services join the membership ring and acquire shards
(Not enough hosts, shard status unknown, context canceled, the cluster metadata race, Frontend is not healthy
yet) go to debug level; a fresh PostgreSQL start with 512 shards logged about 400 of them, now none.

Also refuses service ports whose membership port (port - 300) exceeds 32767 on PostgreSQL and MySQL: Temporal
stores it in a SMALLINT column and membership fails at start otherwise.
The launcher ships as bin/workflow-runtime and the engine's profile for the API server is api, not manager.
start-dev --ip 0.0.0.0 left engine.broadcastAddress empty, which the configuration refuses; dev now sets it to auto.
A fresh distribution has no data/ and SQLite creates the file but not its directory, so the quick-start's
start-dev --db-file data/dev.db exited with "unable to open database file". start-dev now creates missing
directories and names --db-file when it cannot.
cli_test reads the dev namespaces back from SQLite with their WorkflowKind alias and covers the --db-file
directory. tools/internal/enginetest/dev_test.go starts a real start-dev with no outside setup: default and
--namespace exist with WorkflowKind, a first workflow tagged with it is found by a visibility query, and both
survive a restart on the same file. balsuite --database dev runs the Ballerina suites on start-dev without
creating the namespace or search attribute, and the smoke matrix now includes it.
Dev mode wrote namespaces through Temporal's SQL persistence from the cli package; the new SQL boundary rule
refuses that, so the code and its SQLite test move to internal/sqlschema.
@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

This review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry.

Next included review available in 53 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 2fe405e and 004f408.

Files selected for processing: 37

  • .github/workflows/ballerina-tests.yml
  • AGENTS.md
  • README.md
  • distribution/README.dist.md
  • docs/features/distribution.md
  • docs/features/engine.md
  • docs/features/runtime-config.md
  • docs/guides/ARCHITECTURE.md
  • docs/guides/DEVELOPING.md
  • docs/guides/TESTING.md
  • docs/user-guide/README.md
  • docs/user-guide/configure.md
  • docs/user-guide/connect-an-integration.md
  • docs/user-guide/install.md
  • docs/user-guide/monitor.md
  • docs/user-guide/quick-start.md
  • docs/user-guide/reference/runtime-toml.md
  • docs/user-guide/run-in-containers.md
  • docs/user-guide/troubleshoot.md
  • docs/user-guide/workflow-runtime.md
  • engine/internal/cli/cli.go
  • engine/internal/cli/cli_test.go
  • engine/internal/cli/quietlog.go
  • engine/internal/cli/quietlog_test.go
  • engine/internal/launcher/launcher.go
  • engine/internal/launcher/launcher_test.go
  • engine/internal/runtimeconfig/dev.go
  • engine/internal/runtimeconfig/runtimeconfig.go
  • engine/internal/runtimeconfig/security_test.go
  • engine/internal/sqlschema/devnamespaces.go
  • engine/internal/sqlschema/devnamespaces_test.go
  • launcher/README.md
  • tools/cmd/balsuite/main.go
  • tools/internal/balsuite/balsuite.go
  • tools/internal/balsuite/balsuite_test.go
  • tools/internal/balsuite/upgrade.go
  • tools/internal/enginetest/dev_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

heshanpadmasiri
heshanpadmasiri previously approved these changes Nov 4, 2026

@heshanpadmasiri heshanpadmasiri left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@heshanpadmasiri heshanpadmasiri left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of commit f18ad4152d0567dc327330eafa1e889b9e7fe08e.

One confirmed finding is attached inline.

Validation: focused Go tests passed; the stack-tip coverage gate passed at 92.7%. The real-engine reset test passed, and a cron schedule round trip reproduced the schedule display finding. Ballerina smoke testing did not run successfully because the external Temporal CLI was unavailable.

now func() time.Time
}

func newQuietLogger(l log.Logger) log.Logger {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] Preserve the source position of non-Error log messages

Description: The constructor applies Skip(1) to the embedded logger, but only Error adds an explicit forwarding frame (engine/internal/cli/quietlog.go:56). Promoted methods such as Warn, Info and Debug consequently skip the actual logging site and report its caller. This affects ordinary production starts and points operators at the wrong source location during diagnosis.
Reproduction: Ran go test ./engine/internal/cli -run '^TestStartWithIdentityProviderAuth$' -count=1 -v on this PR. The warning emitted at engine/internal/cli/cli.go:318 reported logging-call-at: .../cli.go:230.
Correction: Preserve the original delegate for promoted methods and use an appropriately adjusted delegate for Error, or forward all methods consistently. Assert caller metadata; the existing Zap wrapper test only checks the concrete wrapper type (engine/internal/cli/quietlog_test.go:58).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 7538b5b. quietLogger now embeds the original logger for the promoted methods (Debug, Info, Warn, ...), which add no frame. Only Error, which does add a frame, logs through a Skip(1) copy, both when it logs as an error and when it downgrades to debug.

TestQuietLoggerKeepsTheCallersSourcePosition logs at every level, plus a downgraded transient error, through a real zap logger writing to a file. It asserts that each entry's logging-call-at is the test's own line. Before the fix, it reported testing.go for info, warn and debug. Your reproducer now reports cli.go:318 for the issuer/audience warning.

@CLAassistant

CLAassistant commented Nov 5, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

heshanpadmasiri
heshanpadmasiri previously approved these changes Nov 5, 2026

@heshanpadmasiri heshanpadmasiri left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the current PR diff and relevant implementation, callers, tests and documentation using AGENTS.md, gh-stack, review-loop and review-oracle (Go). No confirmed P3-or-higher introduced findings remain.

Validation: stack-tip build and unit-test coverage gate pass (91.8%); the existing real-engine reset regression passes. PostgreSQL/MySQL and the full Ballerina smoke suite were not verified in this environment.

@hasithaa
hasithaa dismissed heshanpadmasiri’s stale review November 6, 2026 04:02

The merge-base changed after approval.

heshanpadmasiri
heshanpadmasiri previously approved these changes Nov 6, 2026

@heshanpadmasiri heshanpadmasiri left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the current PR diff, relevant implementation, callers, tests and documentation using the repository guidelines, gh-stack, a fresh independent review-loop pass and review-oracle (Go). No confirmed P0–P2 findings in this PR.

Review scope: this PR against its declared base; findings introduced in other stack layers are assigned to those PRs. Full-stack coverage and smoke validation were attempted separately; this approval does not assert that live PostgreSQL/MySQL or Ballerina suites passed.

@heshanpadmasiri heshanpadmasiri left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of this PR's own changes in the stack: 3 finding(s), inline.

}

// quietLogger logs transient start-up errors at debug level during the grace period, everything else unchanged.
type quietLogger struct {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 quietLogger embeds only the log.Logger interface, so it no longer implements log.WithLogger (With) or log.SkipLogger (Skip), although the zap logger it wraps does. Temporal builds nearly every component logger with log.With(logger, tags...) (per service, shard and component) and log.NewThrottledLogger. Without these methods, log.With falls back to its generic withLogger wrapper and the throttled logger cannot add its skip frames. Both add a stack frame that zap's fixed skip does not account for.

Result: on every start and start-dev, for the whole life of the process and not only during the grace period, most engine log lines report the wrong source. For example, log.With(newQuietLogger(zap), tag).Info("x") reports logging-call-at: go.temporal.io/server@v1.32.1/common/log/with_logger.go:42 (:52 for Error), and a throttled logger reports throttle_logger.go:44. The same calls on the unwrapped zap logger report the real caller. The fallback also copies and prepends the tags on every call, including debug calls that are filtered out, where zap's With would have pre-encoded them. TestQuietLoggerKeepsTheCallersSourcePosition misses this because it only calls the root logger directly.

Suggested fix: implement With(tags...) so it returns a quietLogger whose Logger and errors fields are log.With(q.Logger, tags...) and log.With(q.errors, tags...), keeping the same until and now. Implement Skip(n) the same way, forwarding to the inner SkipLogger. Then extend the test to log through log.With(q, ...) and log.NewThrottledLogger(q, ...) and check logging-call-at.


const usageText = `usage: workflow-engine version
workflow-engine start (--runtime-config <runtime.toml> | --config-file <temporal.yaml>) [--service <name>]... [--allow-no-auth]
workflow-engine start-dev [--ip <address>] [--port <port>] [--db-file <file>] [--namespace <name>]... [--log-level <level>]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 This PR adds workflow-engine start-dev (--ip, --port, --db-file, --namespace, --log-level), workflow-runtime dev and the balsuite --database dev option, but it does not change docs/guides/DEVELOPING.md. AGENTS.md rule 1 says a new command or flag must also update the README and DEVELOPING.md. The run section of DEVELOPING.md still documents only start --runtime-config ... --allow-no-auth, and the README mentions only "development mode" in its status line. The troubleshooting row for the missing WorkflowKind search attribute still points only to the balsuite runner, although start-dev now pre-registers that attribute. A contributor reading the developer guide will not find the new dev path.

Suggested fix: add start-dev and its flags, and workflow-runtime dev, to the build-and-run section of DEVELOPING.md. Mention --database dev where balsuite is described, and update the WorkflowKind troubleshooting row. List the command in the README or link the quick start from it.

case "start", "render-config":
engineArgs = append([]string{command, "--runtime-config", config}, rest...)
case "dev":
engineArgs = append([]string{"start-dev"}, rest...)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 run() calls os.Chdir(home) before it starts the engine, which is why it makes WORKFLOW_RUNTIME_CONFIG absolute first ("Relative to where the caller ran the command, not to the home it changes to"). The new dev case passes rest through unchanged, so a relative --db-file is resolved against the runtime home. For example, cd ~/proj && /opt/wfr/bin/workflow-runtime dev --db-file ./dev.db creates and reuses /opt/wfr/dev.db, along with any missing directories there, and not ~/proj/dev.db. The runtime home may not be writable, and nothing in the quick start says the path is relative to it. The launcher test only checks that the argument is passed through.

Suggested fix: before the chdir, make a relative --db-file value (both --db-file x and --db-file=x) absolute against the caller's working directory, as the launcher already does for the config path, and add a test for it. Alternatively, document that the path is relative to the runtime home and test that behavior.

@heshanpadmasiri heshanpadmasiri left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two independent reviews agreed on these findings.

P1 docs (AGENTS.md rule 1): the PR adds workflow-engine start-dev (--ip, --port, --db-file, --namespace, --log-level) and workflow-runtime dev. Neither docs/guides/DEVELOPING.md nor the README documents them. DEVELOPING.md still tells developers to start with start --runtime-config tests/engine/runtime-sqlite.toml --allow-no-auth and to create the namespace by hand. The AGENTS.md Ballerina suites paragraph now lists dev but still says the runner always starts from runtime-<database>.toml and creates the namespace and search attribute, which isn't true for dev.

}

// quietLogger logs transient start-up errors at debug level during the grace period, everything else unchanged.
type quietLogger struct {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: quietLogger embeds the log.Logger interface, so only the level methods are promoted. It implements neither log.WithLogger nor log.SkipLogger, although the zap logger underneath implements both. Temporal builds nearly every component logger with log.With(logger, tag...), which now falls back to the generic *withLogger wrapper. Both reviewers confirmed with a probe test (newQuietLogger(log.NewZapLogger(...)), then log.With(l, tag).Info/Error) that logging-call-at becomes go.temporal.io/server@v1.32.1/common/log/with_logger.go:42 (Info) or :52 (Error) instead of the real caller. serve() wraps the logger for every start, not only start-dev, so operators lose the source position on almost every engine log line for the whole life of the process. A fix: implement With (wrap inner.With(...), keeping errors built the same way) and Skip, then add a test that logs through log.With(...) and checks the source position. TestQuietLoggerKeepsTheCallersSourcePosition only logs through the wrapper directly, so it misses this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in fc1047a. quietLogger now implements With and Skip. With tags through the logger underneath (log.With(q.Logger, ...), so zap's own With) and wraps the result again with the same grace period and the errors logger rebuilt with Skip(1). Skip wraps the inner logger's Skip. TestQuietLoggerKeepsTheCallersSourcePosition now also logs through log.With(l, tag): it checks that the result is still a quietLogger, that logging-call-at is the test's own line for info, error and a transient error, and that the transient error is still downgraded to debug. On the old code it fails with *log.withLogger is not a quiet logger.

Temporal builds component loggers with log.With. Without With and Skip, quietLogger fell back to Temporal's generic wrapper, which logged its own file and line as logging-call-at for nearly every engine log line.
…e/dev-mode

# Conflicts:
#	AGENTS.md
#	README.md
#	docs/guides/ARCHITECTURE.md
#	engine/internal/cli/cli.go
#	engine/internal/cli/cli_test.go
@hasithaa

Copy link
Copy Markdown
Contributor Author

Docs (review's P1) fixed in 004f408:

  • docs/guides/DEVELOPING.md starts "Build and run" with development mode: workflow-engine start-dev and every flag (--ip, --port, --db-file, --namespace, --log-level) with its default, and bin/workflow-runtime dev in a distribution. The --runtime-config steps follow as the production-like way to run, and they now say those configurations create no namespace.
  • The README points to bin/workflow-runtime dev and start-dev for a local engine.
  • AGENTS.md's Ballerina suites paragraph says that --database dev runs start-dev --port 17233 and creates nothing, since development mode does that itself.

@hasithaa

Copy link
Copy Markdown
Contributor Author

Combined into #10 to shorten the review queue: runtime/schema-on-start now holds this PR's commits (#10 = schema on start + packaging + development mode). The review threads here stay as history; open findings are answered per thread.

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.

Run a development Workflow Runtime with one command

3 participants