Skip to content

feat(cli): add agent bridge diagnostics and lifecycle logging#12682

Merged
RCmerci merged 15 commits into
masterfrom
codex/agent-bridge
May 22, 2026
Merged

feat(cli): add agent bridge diagnostics and lifecycle logging#12682
RCmerci merged 15 commits into
masterfrom
codex/agent-bridge

Conversation

@RCmerci
Copy link
Copy Markdown
Contributor

@RCmerci RCmerci commented May 19, 2026

Summary

  • Add agent bridge command support for routing tasks, recording sessions, and listing bridge runs.
  • Improve db-worker-node and CLI server lifecycle logging for startup version, restart mismatch details, and exit reasons.
  • Add AgentBridge session-id built-in property support, including schema migration, property classification, and description metadata.
  • Extend CLI docs, e2e coverage, and db property/schema support for the agent bridge workflow.

Testing

  • Unit tests added/updated for agent bridge routing, exit logging, server restart diagnostics, db-worker-node startup logging, AgentBridge session-id property metadata, and schema migration.
  • bb dev:test -v logseq.cli.command.agent-test/test-agent-bridge-built-in-properties
  • bb dev:test -v frontend.worker.migrate-test/migrate-65-31-adds-agent-session-id-property
  • bb dev:test -v frontend.worker.migrate-test
  • bb dev:test -v logseq.cli.command.agent-test
  • git diff --check
  • logseq-cli compiled successfully.
  • CLI non-sync e2e passed.

@RCmerci RCmerci force-pushed the codex/agent-bridge branch 5 times, most recently from 56435f7 to ec8dc54 Compare May 21, 2026 14:14
@RCmerci RCmerci requested a review from Copilot May 21, 2026 16:12
@RCmerci RCmerci marked this pull request as ready for review May 21, 2026 16:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces an “AgentBridge” workflow to the Logseq CLI for routing assigned tasks/comments to an external agent (Codex), while also improving db-worker-node diagnostics by centralizing lifecycle + stdio logging and adding richer server restart mismatch logs. It also extends the frontend DB schema/migrations and e2e coverage to support the new persisted :logseq.property.agent/session-id field.

Changes:

  • Add logseq agent bridge / logseq agent bridge list commands, prompt-template initialization, session recording, and event-driven routing.
  • Add unified db-worker-node logging (logseq.db-worker.log) and wire it into daemon spawning and db-worker-node startup logging.
  • Extend DB schema/migrations and tests to add Assignee and Agent Session ID built-in properties, plus CLI docs + e2e workflows.

Reviewed changes

Copilot reviewed 36 out of 36 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/test/logseq/db_worker/daemon_test.cljs Extends spawn tests to assert detached stdio redirection env + fd-based stdio config.
src/test/logseq/cli/server_test.cljs Asserts restart-version-mismatch info logging via glogi handler capture.
src/test/logseq/cli/command/agent_test.cljs Adds comprehensive unit tests for agent bridge parsing, routing, prompts, sessions, and event handling.
src/test/frontend/worker/migrate_test.cljs Adds migration test for schema 65.31 creating agent/session-id property and migrate-updates.
src/test/frontend/worker/db_worker_node_test.cljs Updates tests to use unified log module; adds tests for version/stdio logging and retention.
src/resources/dicts/zh-cn.edn Adds :property.built-in/assignee translation.
src/resources/dicts/en.edn Adds :property.built-in/assignee translation.
src/main/logseq/db_worker/log.cljs New unified db-worker-node logging module (file log output + stdio/console wrapping + retention + child stdio helper).
src/main/logseq/db_worker/daemon.cljs Uses unified child stdio redirection for detached db-worker-node spawn; sets env marker.
src/main/logseq/cli/server.cljs Adds structured info log for restart version mismatch before stopping mismatched servers.
src/main/logseq/cli/format.cljs Adds error hints + human formatting for agent bridge logs and session listing.
src/main/logseq/cli/commands.cljs Registers agent command entries; wires agent actions to execution.
src/main/logseq/cli/command/core.cljs Adds agent to top-level utilities group and help description overrides.
src/main/logseq/cli/command/agent.cljs New agent bridge implementation (task/comment routing, prompt templates, Codex invocation, session store, event listener).
src/main/frontend/worker/db/migrate.cljs Adds schema updates 65.30/65.31 for new built-in properties.
src/main/frontend/worker/db_worker_node.cljs Installs unified logging at startup; logs build version; uninstalls on stop.
docs/agent-guide/logseq-cli/001-logseq-cli.md Documents agent bridge command surface and behavior.
deps/db/test/logseq/db/frontend/property_test.cljs Adds property definition tests for Assignee and Agent Session ID.
deps/db/src/logseq/db/frontend/schema.cljs Bumps DB schema version to 65.31.
deps/db/src/logseq/db/frontend/property.cljs Adds built-in Assignee and Agent Session ID property definitions; includes logseq.property.agent namespace.
cli-e2e/spec/non_sync_inventory.edn Registers agent commands/options in CLI non-sync inventory.
cli-e2e/spec/non_sync_cases.edn Adds non-sync e2e cases covering agent bridge workflows and prompt-template graph isolation.
cli-e2e/scripts/agent_bridge_e2e.py New Python harness for fake Codex + agent bridge end-to-end checks.
cli-e2e/scripts/agent_bridge_demo.sh New shell demo script validating live bridge routing and writeback with a fake Codex.
.agents/skills/logseq-review-workflow/SKILL.md Updates the review workflow skill to subagent-based pass orchestration and migration contract emphasis.
.agents/skills/logseq-review-workflow/rules/README.md Notes pass rule files under passes/.
.agents/skills/logseq-review-workflow/rules/passes/test-coverage.md New subagent pass guidance for test coverage review.
.agents/skills/logseq-review-workflow/rules/passes/subagent-output.md New output contract for pass subagents.
.agents/skills/logseq-review-workflow/rules/passes/repository-convention.md New repository convention pass definition.
.agents/skills/logseq-review-workflow/rules/passes/regression.md New regression pass definition.
.agents/skills/logseq-review-workflow/rules/passes/performance.md New performance pass definition.
.agents/skills/logseq-review-workflow/rules/passes/migration-validation.md New migration-validation pass definition.
.agents/skills/logseq-review-workflow/rules/passes/failure-mode.md New failure-mode pass definition.
.agents/skills/logseq-review-workflow/rules/passes/data-contract.md New data-contract pass definition.
.agents/skills/logseq-review-workflow/rules/passes/correctness.md New correctness pass definition.
.agents/skills/logseq-cli/SKILL.md Updates CLI skill docs to include agent bridge tips and command list.
Comments suppressed due to low confidence (1)

src/main/frontend/worker/db_worker_node.cljs:578

  • start-daemon! installs the db-worker log wrappers early, but in the p/catch error path it only removes the lock and rethrows. If startup fails after db-worker-log/install! (e.g. lock acquisition / DB init error), the wrapped console/*print-fn*/process streams can remain installed for the rest of the process lifetime (including subsequent retries/tests). Consider ensuring db-worker-log/uninstall! runs on startup failure (e.g. in the p/catch or via p/finally).
          (db-worker-log/install! {:root-dir root-dir
                                   :repo repo
                                   :log-level (keyword (or log-level "info"))})
          (log/info :db-worker-node-version {:build-time (build-version/build-time)
                                             :revision (build-version/revision)})
          (reset! *ready? false)
          (reset! *lock-info nil)
          (reset! *server-list-file server-list-file)
          (set-main-thread-stub!)
          (-> (p/let [platform (platform-node/node-platform {:root-dir root-dir
                                                             :event-fn handle-event!
                                                             :write-guard-fn assert-lock-owner!
                                                             :owner-source owner-source
                                                             :recreate-lock-fn recreate-lock!})
                      proxy (db-core/init-core! platform)
                      _ (<init-worker! proxy)
                      {:keys [path lock]} (db-lock/ensure-lock! {:root-dir root-dir
                                                                 :repo repo
                                                                 :owner-source owner-source})
                      _ (reset! *lock-info {:path path :lock lock})
                      _ (let [method-kw :thread-api/create-or-open-db
                              method-str (normalize-method-str method-kw)]
                          (<invoke! proxy method-str method-kw [repo (startup-db-opts opts)]))]
                (start-http-server! {:proxy proxy
                                     :repo repo
                                     :host host
                                     :port port
                                     :owner-source owner-source
                                     :root-dir root-dir
                                     :on-stopped! on-stopped!}))
              (p/catch (fn [e]
                         (when-let [lock-path (:path @*lock-info)]
                           (db-lock/remove-lock! lock-path))
                         (throw e)))))

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/logseq/db_worker/log.cljs Outdated
(or (.-stack value) (.-message value) (str value))

(and value (fn? (.-toString value)))
(.toString value (or encoding "utf8"))
Comment on lines +1055 to +1077
(defn- show-task-tree
[cfg repo block]
(p/let [show-result (show-command/execute-show {:type :show
:repo repo
:uuid (block-uuid-str block)
:level 100
:linked-references? false
:ref-id-footer? false}
cfg)]
(or (get-in show-result [:data :message])
(:block/title block))))

(defn- show-block-tree
[cfg repo block]
(p/let [show-result (show-command/execute-show {:type :show
:repo repo
:uuid (block-uuid-str block)
:level 100
:linked-references? false
:ref-id-footer? false}
cfg)]
(or (get-in show-result [:data :message])
(:block/title block))))
Comment on lines +1027 to +1037
(defn- pull-assignee-property
[cfg repo]
(transport/invoke cfg :thread-api/pull [repo assignee-property-selector assignee-property-ident]))

(defn- resolve-assignee-datoms
[cfg repo tx-data]
(let [direct-datoms (filter direct-assignee-datom? tx-data)
unknown-attr-datoms (filter unknown-attr-datom? tx-data)]
(if (seq unknown-attr-datoms)
(p/let [property (pull-assignee-property cfg repo)
property-id (:db/id property)]
@tiensonqin tiensonqin force-pushed the codex/agent-bridge branch from 26e9818 to b960190 Compare May 22, 2026 06:00
@RCmerci RCmerci force-pushed the codex/agent-bridge branch from b960190 to b6b182f Compare May 22, 2026 07:56
@RCmerci RCmerci merged commit e9e4445 into master May 22, 2026
26 checks passed
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.

2 participants