engine: zero-config local mode on :7654 (HAL-186)#42
Conversation
…7654 Adds a local mode that moves the base config to zero-setup defaults BEFORE the file/env layers (which still override): listen on :7654, a localhost Postgres URL matching the bundled/dev database, local file storage, and the Postgres-backed river queue (no Redis needed). The engine then boots with no required configuration — closing the 'database.url is required' gap that otherwise blocks a bare run. - --local flag sets VLE_LOCAL_MODE=true so CLI + Docker (env) share one path. - Adds VLE_STORAGE_LOCAL_ROOT binding for the image's data volume. - cmd/engine is already unauthenticated (single tenant), so local-mode auth needs no extra wiring; documented as dev/local only. - Documented in config.example.yaml; tests cover defaults, truthy forms, env-override precedence, and the non-local missing-DB-URL failure. Foundation for the all-in-one image (HAL-185) + local dashboard (HAL-188). Closes HAL-186.
Reviewer's GuideAdds a zero-config local mode for the engine that, when enabled via a flag or env var, rewrites the base configuration to boot on :7654 with a localhost Postgres, local storage, and a Postgres-backed river queue, while keeping existing config precedence and non-local behavior intact, plus associated env bindings, logging, tests, and documentation updates. Flow diagram for zero-config local mode configuration loadingflowchart TD
A[engine_main.run] --> B[flag.Parse]
B --> C{--local flag set?}
C -- yes --> D[os.Setenv VLE_LOCAL_MODE=true]
C -- no --> E[env unchanged]
D --> F[config.Load]
E --> F[config.Load]
subgraph Load
F --> G[Default]
G --> H{LocalModeEnabled}
H -- true --> I[applyLocalDefaults]
H -- false --> J[skip local defaults]
I --> K{configPath provided?}
J --> K
K -- yes --> L[read YAML file]
K -- no --> M[skip file]
L --> N[applyEnvOverrides]
M --> N[applyEnvOverrides]
end
I --> I1[Server.Addr = :7654]
I --> I2[Database.URL = defaultLocalDatabaseURL]
I --> I3[Storage.Driver = local; set Storage.Local.Root if empty]
I --> I4[Queue.Driver = river]
N --> O[engine starts with final Config]
O --> P[logger.Info local_mode=config.LocalModeEnabled]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
📝 WalkthroughWalkthroughAdds zero-config local mode to the engine. ChangesZero-config Local Mode
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@config.example.yaml`:
- Around line 20-22: The documented Postgres URL in the comment block differs
from the actual default configuration. Update the example Postgres URL in the
comment from `postgres://vectorless:vectorless@localhost:5432/vectorless` to
`postgres://vectorless:vectorless@localhost:5432/vectorless?sslmode=disable` to
match the real default used in pkg/config/config.go, ensuring the documentation
accurately reflects the actual configuration that gets injected in local mode.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7c9785c4-e768-4e55-b1ae-83b86a9ea9d2
📒 Files selected for processing (4)
cmd/engine/main.goconfig.example.yamlpkg/config/config.gopkg/config/config_local_test.go
| # at all: it listens on :7654, points at a localhost Postgres | ||
| # (postgres://vectorless:vectorless@localhost:5432/vectorless), uses local | ||
| # file storage and the Postgres-backed river queue, and requires no API key |
There was a problem hiding this comment.
Align the documented local Postgres URL with the actual default.
The comment block shows postgres://vectorless:vectorless@localhost:5432/vectorless, but local mode actually defaults to .../vectorless?sslmode=disable in pkg/config/config.go. Please update this string to match the real injected default to avoid copy/paste confusion.
Proposed doc fix
-# (postgres://vectorless:vectorless@localhost:5432/vectorless), uses local
+# (postgres://vectorless:vectorless@localhost:5432/vectorless?sslmode=disable), uses local📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # at all: it listens on :7654, points at a localhost Postgres | |
| # (postgres://vectorless:vectorless@localhost:5432/vectorless), uses local | |
| # file storage and the Postgres-backed river queue, and requires no API key | |
| # at all: it listens on :7654, points at a localhost Postgres | |
| # (postgres://vectorless:vectorless@localhost:5432/vectorless?sslmode=disable), uses local | |
| # file storage and the Postgres-backed river queue, and requires no API key |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@config.example.yaml` around lines 20 - 22, The documented Postgres URL in the
comment block differs from the actual default configuration. Update the example
Postgres URL in the comment from
`postgres://vectorless:vectorless@localhost:5432/vectorless` to
`postgres://vectorless:vectorless@localhost:5432/vectorless?sslmode=disable` to
match the real default used in pkg/config/config.go, ensuring the documentation
accurately reflects the actual configuration that gets injected in local mode.
What
Adds zero-config local mode —
engine --local(orVLE_LOCAL_MODE=true) — so the engine boots with no setup on the canonical port :7654. This is the keystone for the all-in-one Docker image (HAL-185) and the local dashboard (HAL-188): both need the engine to serve on :7654 with no required configuration.How
Local mode rewrites the base config before the YAML-file and env layers, so any explicit value still wins — it only moves the starting point:
postgres://vectorless:vectorless@localhost:5432/vectorless) — this closes the one "required env" gap (database.url is required when queue.driver=river)Plus:
--localflag setsVLE_LOCAL_MODE=true, so the CLI flag and the Docker image (env) share one code path.VLE_STORAGE_LOCAL_ROOTenv binding for the image's data volume.cmd/engineis already unauthenticated (single logical tenant, no API key), so "local-mode auth" needs no extra wiring — documented as dev/local only, not for the public internet.Tests
config_local_test.go: defaults boot valid with nothing else set; truthy-form parsing; env overrides beat local defaults; non-local behaviour unchanged (:8080); and the non-local missing-DB-URL still fails validation (proving local mode is what removes the gap).go build/test/gofmt/vetclean.Docs
config.example.yamlgains a "Zero-config local mode" section.Closes HAL-186
Summary by Sourcery
Introduce a zero-config local mode that lets the engine start on :7654 with sensible local defaults and minimal required configuration.
New Features:
Enhancements:
Documentation:
Tests:
Summary by CodeRabbit
New Features
--localCLI flag enabling zero-config local development mode with automatic defaults for server address, database, storage, and queue configuration.Documentation