Skip to content

feat(database): per-family database engine selection - #173755

Merged
steipete merged 8 commits into
mainfrom
pgprep/mixed-mode-proto
Oct 16, 2026
Merged

steipete merged 8 commits into
mainfrom
pgprep/mixed-mode-proto

Conversation

@steipete

@steipete steipete commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Peter approved the config shape on 2026-10-16: database.engine remains the default; optional database.families.{state,agent,workboard,logbook,team-reports}.engine overrides share database.postgres. Safety journals stay fixed local. No per-family DSN/prefix or per-agent settings.

One context owner carries the full effective family map and resolved PostgreSQL input. Gateway boot installation is immutable and rejects conflicting reinstalls. Offline port work uses the existing task-scoped selection, including the complete family map, so retained workers can follow source/target transitions without rebinding the Gateway. State and plugin openers consume their selected families; agent/auth/inspection consumers now use the agent family. Doctor reports default, override, and effective selections without connection details.

Rebased onto current main with R4 agent routing, R13 state port/backup, Doctor PostgreSQL migration proof, and the worker-task scope repair. Homogeneous PostgreSQL includes agents. PostgreSQL agents combined with any SQLite configurable family refuse with DATABASE_AGENT_MIXED_POSTGRES_UNSUPPORTED until PR3 mixed-pair conformance; explicit SQLite agents remain valid. The minimal state-preflight hunk is retained; schemafp #173617 will rebase after PR1.

Safety and remaining work

Mixed-engine database port, snapshot backup/restore, and update preflight refuse before mutation with an actionable single-engine/family-scoped-support remedy. Fixed-local safety journals do not count as mixed engines. Config-only archives remain available. Updates also reject explicit family maps until the candidate config contract supports them. Existing stores never silently switch engines or fall back to SQLite; changing a family requires an offline port and restart.

  • PR2: family-scoped port/recovery, backup/restore, and update inventory/admission, building on R13/R14a.
  • PR3: mixed PostgreSQL agent-pair conformance across auth, leases, binding compensation, retirement, and reopen.
  • Team multi-node ownership/routing/failover remains out of scope.

The design decision is summarized above and in the engine guide. No schema format or anchor format changes are introduced.

Evidence

  • 104 focused tests passed for config validation, Doctor, secret activation, update admission, port refusal, and backup/restore behavior.
  • Reused-worker transport (14 tests), immutable/scoped selection (6 tests), and memory family routing (2 tests) passed.
  • Local PostgreSQL proof passed all 12 recovery cases, 21 port-command cases, seven R4 agent cases, and five mixed-mode cases. This includes fresh mixed boots, retained-data mismatch refusal, captured SecretRef across reopen, and homogeneous lifecycle connection selection.
  • SQLite cold/restart/write/read/close capture matches the rebased main byte for byte: all 101 statements are unchanged.
  • Full local PostgreSQL attempt: 225 passed, 10 search tests failed, five skipped, plus one namespace-suite setup failure. The local PG17 server lacks pgvector, and its scratch-database template uses SQL_ASCII; CI uses the pinned pgvector PG17 image with UTF8.
  • Format, scoped core/extension/scripts lint, production and affected test typechecks, config docs/schema/examples, and line-cap/assertion/database-worker/database-dialect/timeout ratchets passed. The type-only CI cycle correction passed a fresh core typecheck, scoped lint, and Madge (zero cycles).
  • One isolated autoreview found stale homogeneous fixtures missing the agent override; those three fixture lines were corrected and the affected tests pass. No additional production findings were reported. CI also caught the schema-to-registry type-import cycle, fixed by making the registry depend only on the engine fields it consumes.
  • Exact-head CI: run 38883095772, head 2d56a0a154b1631df86d025ac5f14127a5368943. Completed successfully: 152 jobs passed and 22 planned jobs skipped. Full PostgreSQL conformance passed, including port-command.recovery.integration.test.ts and the R4 agent cases.

Known inherited local findings, with no baseline or suppression changes:

  • Max-lines flags unchanged suppressions in ui/src/pages/chat/components/chat-message.test.tsx:3214, ui/src/pages/config/config-page-state.ts:1, and ui/src/pages/sessions/sessions-page-state.ts:1596. The result is the same when pinned to the actual PR base.
  • Knip production flags presentSessionRow (rowProjection) in src/gateway/session-utils-row.ts, createLaneQueue in src/process/command-queue.state.ts, presentedContent in ui/src/lit/presentation-binding.ts, mountLitContent in ui/src/lit/solid-content.tsx, and type PluginToolIcon in ui/src/pages/chat/chat-tool-icon-controller.ts.
  • Knip all-exports flags presentedContent, renderActivityGroup in ui/src/pages/chat/components/chat-message-group.test-support.ts, and PluginToolIcon. All listed files are unchanged from the PR base.

A prior-head CI run also failed the unchanged session-list projection test on filesystem-probe counts. A local PR replay reproduced extra stat calls; the untouched-base comparison timed out, so attribution remains unresolved and no session fix is claimed. The final-head CI run passed all selected tests.

Net production TypeScript growth is 285 lines against base 08dd80a42558ef5a5d130f6fd1fc5cd09519fb8e. The existing selection owner and task scope are reused; there is no new runtime registry.

Files overlapping R4
  • docs/reference/database-engines.md
  • extensions/memory-core/src/memory-search-database.ts
  • extensions/memory-core/src/memory/manager-db.engine-admission.test.ts
  • scripts/pr-lib/wrapper-components.txt
  • src/agents/auth-profiles/sqlite-read.ts
  • src/agents/auth-profiles/sqlite.ts
  • src/commands/doctor-database-engine.test.ts
  • src/infra/database-engine/open.ts
  • src/infra/database-engine/registry.test.ts
  • src/infra/database-engine/registry.ts
  • src/infra/sqlite-store.worker.ts
  • src/infra/worker-task-pool.retained.test.ts
  • src/state/openclaw-agent-db-engine.ts
  • src/state/openclaw-agent-db-registry-listing.ts
  • src/state/openclaw-agent-db.postgres.test.ts
  • src/state/openclaw-agent-schema-inspection-worker.ts
  • src/state/openclaw-database-preflight.ts

@steipete steipete added the prototype — do not merge Disposable prototype; do not mark ready or merge. label Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts commands Command implementations plugin: file-transfer plugin: workboard plugin: logbook Logbook automatic work journal plugin plugin: team-reports size: XL labels Oct 16, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR adds per-family database engine overrides and carries the boot-selected engines through plugin stores and workers.

Example: A fresh installation sets database.engine to sqlite and database.families.workboard.engine to postgres.

  • Before: Workboard follows the global SQLite selection.
  • After: Workboard uses PostgreSQL while shared state and agent databases remain on SQLite.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful prototype with meaningful owner-level conformance coverage, an introduced CLI regression, and unproven upgrade compatibility.
Proof confidence 🦐 gold shrimp (3/6) Maintainer authorship exempts this PR from the ordinary contributor media gate; supplied evidence describes an initializer/store-owner harness, while compatibility evidence does not demonstrate upgrading v2026.10.4 with existing settings and data intact.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Operators cannot independently choose SQLite or PostgreSQL for supported store families.
Reason: The maintainer-authored disposable experiment tests a useful storage choice while explicitly withholding production landing and existing-state rollout.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep this maintainer-authored prototype open and unmerged as requested; review found an introduced dependency on PostgreSQL credentials for unrelated plugin commands.

Priority: P2
Reviewed head: b2b98f3fe1d9ef65429a58b86e32b61dcbe1a5b1

Before merge

  • Defer database credential preparation until a command needs a store (P2) - This runs for every runtime plugin CLI registration, before command-owner selection. With an existing database.engine=postgres configuration whose env/file SecretRef is available to the Gateway service but unavailable in the invoking shell, openclaw browser status now throws while resolving database.postgres.connection before its browser registrar runs. That command only needs its existing Gateway connection and previously did not require local PostgreSQL credentials. Scope preparation to database-consuming commands while retaining the shared selection owner.
  • Complete next step - Preserve the explicit do-not-merge hold and resolve GitHub's reported conflicts before any future landing.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.
  • Explain or restore the original intent of Plugin CLI metadata and runtime preparation - fdebe34: Keep command preparation scoped and lazy, with unrelated plugins outside the selected command's runtime scope.

Findings

  • [P2] Defer database credential preparation until a command needs a store — src/plugins/cli-registry-loader.ts:323-327

Provenance

  • Plugin CLI metadata and runtime preparation changes intended behavior without addressing why it exists (fdebe34: Keep command preparation scoped and lazy, with unrelated plugins outside the selected command's runtime scope.)

Tests

  • Missing end-to-end proof: No supplied shipped CLI/Gateway scenario covers mixed-mode operation or unrelated CLI registration with unavailable database credentials, and no latest-stable upgrade run is shown.
Agent review details

How this fits together

Database configuration enters the host selection owner, which resolves one shared PostgreSQL connection and distributes immutable family choices to database workers and plugin stores.

flowchart TD
  A[Database configuration] --> B[Host engine selection]
  B --> C[Immutable family map]
  C --> D[Shared state workers]
  C --> E[Plugin store workers]
  D --> F[SQLite or PostgreSQL]
  E --> F
Loading

Technical review

Best possible solution:

Keep the prototype draft, prepare database credentials only for commands that consume database stores, and complete family-aware lifecycle support before production rollout.

Do we have a high-confidence way to reproduce the issue?

Source tracing shows that a fresh CLI process with database.engine=postgres and an unavailable database connection SecretRef rejects plugin registration before an unrelated browser command reaches its Gateway request; no target code was executed.

Is this the best way to solve the issue?

The immutable family map extends the existing owner coherently, but unconditional database preparation in the generic CLI loader broadens credential requirements beyond database consumers.

Full review comments:

  • [P2] Defer database credential preparation until a command needs a store — src/plugins/cli-registry-loader.ts:323-327
    This runs for every runtime plugin CLI registration, before command-owner selection. With an existing database.engine=postgres configuration whose env/file SecretRef is available to the Gateway service but unavailable in the invoking shell, openclaw browser status now throws while resolving database.postgres.connection before its browser registrar runs. That command only needs its existing Gateway connection and previously did not require local PostgreSQL credentials. Scope preparation to database-consuming commands while retaining the shared selection owner.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.92

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 7bf56c8aa502.

Provenance checked

  • Global engine resolution and process selection changes intended behavior with a stated reason (6b36172: Resolve the engine before shared-state access and retain one immutable host-resolved selection across workers.)
  • Shared adapters, family registration, and anchor refusal keeps the original intent (9dc6466: Centralize physical-store admission and engine behavior while preserving SQLite defaults and refusing silent fallback.)
  • Plugin store connection preparation changes intended behavior with a stated reason (feat(logbook): PostgreSQL support #172842: Plugin stores resolved configured PostgreSQL input before opening their existing worker-owned stores; the prototype explicitly replaces per-open resolution with boot-owned family selection.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Explicit prototype hold: The complete live PR body says the prototype must remain draft and unmerged, limits it to disposable installations, and defers family-aware recovery, backup, and update support; GitHub reports draft=true and mergeable_state=dirty. (b2b98f3fe1d9)
  • Introduced CLI regression: Runtime CLI registration now resolves every configured database family's PostgreSQL connection before selecting command registrars; unavailable credentials reject this preparation before an unrelated command can run. (src/plugins/cli-registry-loader.ts:323, b2b98f3fe1d9)
  • Shipped caller reaches the regression: CLI dispatch registers plugin commands in lazy mode, which selects runtime preparation; browser commands subsequently use Gateway requests rather than opening these database stores. (src/cli/run-main.ts:1313, b2b98f3fe1d9)
  • Current main still uses global selection: Fetched main resolves PostgreSQL only from database.engine and retains a single input, so it does not already implement the proposed family map. (src/infra/database-engine/config.ts:13, 7bf56c8aa502)
  • Accepted experimental scope: The maintainer-authored change expressly excludes mixed-mode port, backup/restore, and update operations; the corresponding warning is recorded in the database-engine documentation. Public docs: docs/reference/database-engines.md. (docs/reference/database-engines.md:106, b2b98f3fe1d9)
  • Behavioral harness and proof limits: The added conformance suite calls the real Gateway database initializer and real store owners, including secret removal and persisted reopen; the linked environment run is cancelled and exposes no artifacts, so it independently establishes no passing runtime result. (src/infra/database-engine/mixed-mode.conformance.test.ts:118, b2b98f3fe1d9)

Likely related people:

  • Peter Steinberger: Raw commit 6b36172 adds src/infra/database-engine/registry.ts:13 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6b3617207ac1; files: src/infra/database-engine/registry.ts)

PR surface

Source +120, Tests +566, Docs +71, Generated 0, Other +2. Total +759 across 62 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 40 239 119 +120
Tests 17 678 112 +566
Docs 2 87 16 +71
Config 0 0 0 0
Generated 2 3 3 0
Other 1 4 2 +2
Total 62 1011 252 +759

Review metrics

Metric Value Why it matters
Production versus test growth Production TypeScript +120 net lines; tests/support +566 net lines The pinned introduced diff confirms that most growth provides mixed-engine persistence and transport coverage.
Configuration and SDK expansion Five optional family overrides; one additional SDK callable The prototype expands the existing configuration and database-engine-runtime contracts without adding an SDK subpath.

Labels

Label changes:

  • add P2: This experimental feature has limited immediate exposure but introduces a concrete plugin CLI failure.
  • add merge-risk: 🚨 compatibility: The PR adds configuration and SDK contracts, and its unconditional credential preparation can break existing unrelated plugin commands.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: This experimental feature has limited immediate exposure but introduces a concrete plugin CLI failure.
  • merge-risk: 🚨 compatibility: The PR adds configuration and SDK contracts, and its unconditional credential preparation can break existing unrelated plugin commands.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 16, 2026, 12:06 AM ET / 04:06 UTC.

@steipete
steipete force-pushed the pgprep/mixed-mode-proto branch 2 times, most recently from 847ac72 to 1619903 Compare October 16, 2026 05:02
@steipete steipete removed the prototype — do not merge Disposable prototype; do not mark ready or merge. label Oct 16, 2026
@steipete steipete changed the title prototype(database): per-family engine selection (mixed mode) — do not merge feat(database): per-family database engine selection Oct 16, 2026
@steipete
steipete marked this pull request as ready for review October 16, 2026 05:02
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T09:57:01.960028Z 2d56a0a New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 2d56a0a154b1631df86d025ac5f14127a5368943
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/auth-profiles/sqlite-read.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/sqlite.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/secrets/runtime-config-collectors-core.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1619903455

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/infra/database-engine/config.ts Outdated
export type { DatabaseEngineInput } from "./types.js";

/** Resolve on the host; the existing broker input transport keeps credentials out of config/logs. */
export async function resolveDatabaseEngineInput(
config: OpenClawConfig,
env: NodeJS.ProcessEnv = process.env,
): Promise<DatabaseEngineInput> {
if (config.database?.engine !== "postgres") {
return undefined;
return (await resolveDatabaseEngineSelection(config, env)).postgres;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge Preserve the public resolver's default-engine semantics

When database.engine is "sqlite" but a built-in family such as state overrides to "postgres", this retained public SDK helper now returns the PostgreSQL connection. Third-party engine-aware plugins are still documented to call resolveDatabaseEngineInput(config) and cannot specify one of the new built-in family IDs, so an existing plugin store may fail admission as an unported SQLite-to-PostgreSQL switch—or a fresh store may be created in PostgreSQL—even though the operator only selected PostgreSQL for shared state. Keep this resolver tied to the default engine for compatibility while bundled family-aware stores use getDatabaseEngineInput(family).

AGENTS.md reference: AGENTS.md:L57-L57

Useful? React with 👍 / 👎.

@steipete
steipete force-pushed the pgprep/mixed-mode-proto branch from 898e2ba to c375285 Compare October 16, 2026 05:53

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c375285916

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +70 to +73
const engines = new Set(
stores.filter((store) => store.postgres).map((store) => selectDatabaseEngine(store, config)),
);
if (engines.size > 1) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge Route homogeneous overrides through lifecycle connections

When database.engine is sqlite and all four PostgreSQL-capable families explicitly override to postgres, this set has size 1 and admits backup/restore. Those paths later call withDatabasePortConnection in port-provider.ts, which deliberately uses the public default-engine resolver; it therefore receives undefined and fails every anchored PostgreSQL store with PostgreSQL requires database.engine=postgres. Either reject effective/default divergence until family-scoped lifecycle support exists or make these lifecycle paths resolve the anchored family’s connection.

AGENTS.md reference: AGENTS.md:L52-L53

Useful? React with 👍 / 👎.

Comment on lines 34 to 37
// A capable target cannot strand a PostgreSQL store. Avoid copying live databases
// to rediscover their engines at every candidate inspection and activation boundary.
if (Array.isArray(targetEngines) && targetEngines.includes("postgres")) {
if (supportsPostgres) {
return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Require a family-selection capability from update targets

For a homogeneous configuration whose family overrides invert the default—for example, default SQLite with every capable family on PostgreSQL—any pre-family target still advertises databaseEngines: ["sqlite", "postgres"], so this early return accepts an explicit --tag downgrade even though that target cannot interpret the overrides and will select SQLite from the default (or reject the new config only after mutation). Add a target capability/protocol marker for family selection and refuse such targets before activation.

AGENTS.md reference: AGENTS.md:L81-L82

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6990f094bb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

},
input,
),
const selectedDatabase = getDatabaseEngineInput("workboard");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge Install family selection before standalone agent plugin loads

When a standalone agent command loads an enabled Workboard plugin, runLocalAgentCommand reaches withAgentPluginRegistry without any call to installDatabaseEngineSelection (src/agents/agent-command-local.ts:92-96). This lookup therefore returns undefined even when database.families.workboard.engine selects PostgreSQL: an existing PostgreSQL anchor makes the agent command fail, while a fresh installation creates a SQLite store that the next Gateway boot refuses as an engine mismatch. Initialize the immutable selection for this direct-host entry point before loading its plugins.

AGENTS.md reference: AGENTS.md:L50-L53

Useful? React with 👍 / 👎.

Comment on lines +288 to +290
const { resolveDatabaseEngineSelection } = await import("../infra/database-engine/config.js");
installDatabaseEngineSelection(
await resolveDatabaseEngineSelection(context.config, context.env),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Resolve only the CLI plugin's selected database family

For a supported mixed configuration such as PostgreSQL state with SQLite Workboard, invoking openclaw workboard ... enters this branch and resolves the entire family selection. If the state DSN is available only to the Gateway service—as is common for an env SecretRef—the Workboard CLI now fails on that unrelated credential even though its own store is SQLite and previously needed no PostgreSQL input. Prepare the selected plugin families without resolving credentials used exclusively by other families.

AGENTS.md reference: AGENTS.md:L51-L53

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

💡 Codex Review

const selectedDatabase = getDatabaseEngineInput("workboard");

P1 Badge Install family selection before standalone agent plugin loads

When a standalone agent command loads an enabled Workboard plugin, runLocalAgentCommand reaches withAgentPluginRegistry without any call to installDatabaseEngineSelection (src/agents/agent-command-local.ts:92-96). This lookup therefore returns undefined even when database.families.workboard.engine selects PostgreSQL: an existing PostgreSQL anchor makes the agent command fail, while a fresh installation creates a SQLite store that the next Gateway boot refuses as an engine mismatch. Initialize the immutable selection for this direct-host entry point before loading its plugins.

AGENTS.md reference: AGENTS.md:L50-L53


const { resolveDatabaseEngineSelection } = await import("../infra/database-engine/config.js");
installDatabaseEngineSelection(
await resolveDatabaseEngineSelection(context.config, context.env),

P2 Badge Resolve only the CLI plugin's selected database family

For a supported mixed configuration such as PostgreSQL state with SQLite Workboard, invoking openclaw workboard ... enters this branch and resolves the entire family selection. If the state DSN is available only to the Gateway service—as is common for an env SecretRef—the Workboard CLI now fails on that unrelated credential even though its own store is SQLite and previously needed no PostgreSQL input. Prepare the selected plugin families without resolving credentials used exclusively by other families.

AGENTS.md reference: AGENTS.md:L51-L53

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@steipete
steipete force-pushed the pgprep/mixed-mode-proto branch from 6990f09 to 60a075d Compare October 16, 2026 09:40
@openclaw-barnacle openclaw-barnacle Bot added extensions: memory-core Extension: memory-core agents Agent runtime and tooling labels Oct 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 60a075d69f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +14 to +16
return config.database?.engine === "postgres"
? resolveDatabasePostgresInput(config, env)
: undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge Resolve restore admission using the owning family

When database.engine is sqlite but every configurable family explicitly overrides to postgres, the homogeneous-engine guard permits backup and restore and withDatabasePortConnection successfully restores the PostgreSQL namespace. However, preparePostgresRestoreInWorker still calls this now default-only resolver and passes undefined to descriptor.admit, so the family owner tries to admit the restored PostgreSQL anchor as SQLite and the restore fails. Resolve the input from manifest.source.owner and the effective family selection before admitting the restored anchor.

AGENTS.md reference: AGENTS.md:L50-L53

Useful? React with 👍 / 👎.

Comment on lines +283 to +286
!getDatabaseEngineSelection() &&
listDatabaseEngineStores().some(
({ id, postgres }) => postgres && (!onlyPluginIds || onlyPluginIds.includes(id)),
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge Initialize family selection for diagnostic runtime loads

When Workboard is enabled with its family configured for PostgreSQL, selection is initialized only in this plugin CLI-command path; openclaw plugins inspect workboard --runtime and openclaw plugins doctor instead load the full runtime through withPluginDiagnosticsReportForInspection. Workboard registration eagerly opens its store, so getDatabaseEngineInput("workboard") returns undefined: a fresh diagnostic invocation can bootstrap SQLite, after which Gateway startup refuses the configured PostgreSQL engine, while an existing PostgreSQL anchor makes diagnostics fail. Prepare the immutable selection before these diagnostic full-runtime loads as well.

AGENTS.md reference: AGENTS.md:L50-L53

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2d56a0a154

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +74 to +75
function familySetting(schema: StoreSchema): string {
return `database.families.${schema.id === "team_reports" ? "team-reports" : schema.id}.engine`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Preserve default-engine guidance for external stores

When a third-party engine-aware plugin calls the public openEngineStore API with a schema ID such as acme, this helper produces database.families.acme.engine; however, the config schema accepts family overrides only for the five built-in IDs, and external stores still select PostgreSQL through database.engine. Every anchor or engine-mismatch refusal for such a plugin therefore directs the operator to an invalid configuration key. Use family-specific guidance only for registered built-in families and retain database.engine guidance for external schema IDs.

AGENTS.md reference: AGENTS.md:L57-L57

Useful? React with 👍 / 👎.

@steipete
steipete merged commit 995a9ae into main Oct 16, 2026
252 of 255 checks passed
@steipete
steipete deleted the pgprep/mixed-mode-proto branch October 16, 2026 10:19
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
* feat(database): prototype per-family engine selection

Draft prototype only. Config approval and family-aware recovery remain pending.

* feat(database): guard mixed-engine lifecycle operations

* test(database): carry family selection in maintenance fixtures

* fix(database): preserve backup and plugin loading boundaries

* fix(database): preserve default resolver and lazy CLI preparation

* fix(database): close homogeneous lifecycle admission gaps

* fix(database): integrate mixed selections with scoped workers

* fix(database): decouple engine registry config types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations docs Improvements or additions to documentation extensions: memory-core Extension: memory-core gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. plugin: file-transfer plugin: logbook Logbook automatic work journal plugin plugin: team-reports plugin: workboard rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts security-sensitive-changed size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant