Skip to content

engine: zero-config local mode on :7654 (HAL-186)#42

Open
hallelx2 wants to merge 2 commits into
mainfrom
halleluyaholudele/hal-186-engine-zero-config-local-mode
Open

engine: zero-config local mode on :7654 (HAL-186)#42
hallelx2 wants to merge 2 commits into
mainfrom
halleluyaholudele/hal-186-engine-zero-config-local-mode

Conversation

@hallelx2

@hallelx2 hallelx2 commented Jun 17, 2026

Copy link
Copy Markdown
Owner

What

Adds zero-config local modeengine --local (or VLE_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:

  • listen on :7654 (vs :8080)
  • localhost Postgres URL matching the bundled/dev DB (postgres://vectorless:vectorless@localhost:5432/vectorless) — this closes the one "required env" gap (database.url is required when queue.driver=river)
  • local file storage + Postgres-backed river queue (no Redis needed)

Plus:

  • --local flag sets VLE_LOCAL_MODE=true, so the CLI flag and the Docker image (env) share one code path.
  • new VLE_STORAGE_LOCAL_ROOT env binding for the image's data volume.
  • Auth: cmd/engine is 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/vet clean.

Docs

config.example.yaml gains 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:

  • Add zero-config local mode triggered by the --local CLI flag or VLE_LOCAL_MODE env variable, defaulting the engine to listen on :7654 with a local Postgres-backed setup.
  • Add support for configuring a local storage root via the VLE_STORAGE_LOCAL_ROOT environment variable.

Enhancements:

  • Log whether local mode is enabled when starting the engine to aid observability of runtime configuration.

Documentation:

  • Document zero-config local mode usage, behavior, and override examples in config.example.yaml.

Tests:

  • Add configuration tests covering local mode defaults, truthy env parsing, env override precedence, and preservation of non-local default behavior and validation semantics.

Summary by CodeRabbit

  • New Features

    • Added --local CLI flag enabling zero-config local development mode with automatic defaults for server address, database, storage, and queue configuration.
  • Documentation

    • Added local mode setup guide explaining defaults and LLM provider requirements for ingestion and retrieval operations.

…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.
@sourcery-ai

sourcery-ai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds 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 loading

flowchart 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]
Loading

File-Level Changes

Change Details Files
Introduce zero-config local mode that rewrites base configuration before file/env layers when VLE_LOCAL_MODE is enabled.
  • Add localDefaultAddr and defaultLocalDatabaseURL constants for canonical local listen address and Postgres DSN.
  • Implement LocalModeEnabled helper to parse truthy VLE_LOCAL_MODE values.
  • Implement applyLocalDefaults to set :7654 server address, local Postgres URL, local storage driver/root, and river queue driver on the base Config before YAML/env overrides.
  • Update Load to conditionally apply local defaults based on LocalModeEnabled before reading any config file or env overrides.
pkg/config/config.go
Extend configuration env bindings to support overriding local storage root in both normal and local modes.
  • Add VLE_STORAGE_LOCAL_ROOT environment variable handling to set Storage.Local.Root in applyEnvOverrides.
  • Ensure env override ordering remains consistent with existing env bindings for storage and queue drivers.
pkg/config/config.go
Expose a CLI entry point for local mode and surface its status in startup logging.
  • Add --local flag to the engine CLI that sets VLE_LOCAL_MODE=true before config.Load is called.
  • Include local_mode field in startup logger.Info call using config.LocalModeEnabled().
cmd/engine/main.go
Document zero-config local mode behavior and how to override its defaults.
  • Add a "Zero-config local mode" section to config.example.yaml explaining engine --local / VLE_LOCAL_MODE, the :7654 port, default Postgres DSN, storage/queue behavior, API-key-less access, and security caveats.
  • Provide examples of overriding local defaults via env vars such as VLE_SERVER_ADDR and VLE_STORAGE_LOCAL_ROOT.
config.example.yaml
Add tests to validate local mode behavior, env parsing, override precedence, and non-local regression safety.
  • Test that with VLE_LOCAL_MODE set, Load with no file/env produces a fully valid config with :7654, local Postgres URL, local storage driver/root, and river queue driver.
  • Test LocalModeEnabled truthy parsing for multiple accepted values and that non-truthy values do not enable local mode.
  • Test that env vars override local defaults for server addr, database URL, and local storage root when VLE_LOCAL_MODE is enabled.
  • Test that without local mode the historical defaults still apply (server addr :8080) when a DB URL is supplied for validation.
  • Test that without local mode and without a DB URL, Load fails validation, demonstrating that local mode is what fills the DB URL gap.
pkg/config/config_local_test.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot 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.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Caution

Review failed

An error occurred during the review process. Please try again later.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch halleluyaholudele/hal-186-engine-zero-config-local-mode

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between c15175a and 7d95eb1.

📒 Files selected for processing (4)
  • cmd/engine/main.go
  • config.example.yaml
  • pkg/config/config.go
  • pkg/config/config_local_test.go

Comment thread config.example.yaml
Comment on lines +20 to +22
# 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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.

Suggested change
# 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.

…mode=disable)

Per CodeRabbit review on #42 — the example referenced the DSN without the
sslmode param that applyLocalDefaults actually injects.
@hallelx2

Copy link
Copy Markdown
Owner Author

Fixed — aligned the documented DSN to include ?sslmode=disable to match the injected default. Thanks @coderabbitai.

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