Repository navigation
fix(cli): don't set up plugin store in checks - #706
Conversation
disable_startup_writes() only turned off index creation through the db section, so gateway apps without one still set up their plugin store. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Also say in the docs that the setup() of plugins still runs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThe PR prevents check-config and related non-startup-write CLI paths from initializing gateway plugin stores by adding an explicit Foca startup-writes state honored by create_app(), while preserving normal startup and create-indexes behavior; documentation and regression tests cover both database-configured and database-free gateways. Sequence diagram for disabling plugin store setup during CLI checkssequenceDiagram
participant CLI
participant Foca
participant App
participant PluginHost
CLI->>Foca: disable_startup_writes()
Foca->>Foca: _startup_writes = False
Foca->>Foca: db.create_indexes_on_startup = False
CLI->>Foca: create_app()
Foca->>App: create_app()
App->>PluginHost: runtime.create_host()
Note over App,PluginHost: Plugin store setup is skipped when _startup_writes is false
PluginHost-->>App: host without initialized plugin store
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #706 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 66 66
Lines 8597 8599 +2
=========================================
+ Hits 8597 8599 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="foca/foca.py" line_range="236" />
<code_context>
if self.gateway is not None:
- create_indexes = self.conf.db is None or (
- self.conf.db.create_indexes_on_startup
+ create_indexes = self._startup_writes and (
+ self.conf.db is None or self.conf.db.create_indexes_on_startup
)
</code_context>
<issue_to_address>
**Check still initializes plugin store**
When a `create_app()` call and `disable_startup_writes()` run concurrently on the same `Foca` instance, with the app call reading the flag first, `create_app()` snapshots `_startup_writes` as `True`, then a concurrent `disable_startup_writes()` sets it to `False` and returns; the first call still reaches `host.setup_store()`, so the check initializes the plugin store.
Synchronize disabling with the check-and-setup sequence, or pass the write policy as a per-call option so disabling cannot race with an in-progress app creation.
</issue_to_address>Linked issues
#705 fix: check-config writes to the plugin store · 3 of 3 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | check-config writes nothing to the plugin store's backend, with and without a db section. |
✅ Met | disable_startup_writes() sets _startup_writes to false, and create_app() skips host.setup_store() when that flag is false. |
| 2 | A test covers the gateway case without a db section. |
✅ Met | test_no_store_of_gateway_without_writes is parameterized for both db=None and a configured db section. |
| 3 | Remove the exception from docs/cli.md. |
✅ Met | The documentation now says gateway plugin stores are not set up during checks, with or without a db section. |
Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: foca/foca.py:236
Closes #705
Summary
disable_startup_writes()only switched off store setup throughdb.create_indexes_on_startup, so a gateway app without adbsection still ransetup_store()undercheck-config(andsync-policiesandexport-spec, which use the same path). It now also sets a flag on theFocainstance thatcreate_app()honours, with or withoutdb. Normal startup andcreate-indexesdon't change.Findings on the issue's premise
Traced in the code, not on a running gateway:
db.dbs,PluginHost.from_config()keeps the store in memory, so the case in the issue touched the process's own memory rather than a database. The fix still meets the acceptance criteria, and the command no longer depends on that.setup(config). FOCA passes it no store, and creatingMongoStoreBackenddoesn't write, so FOCA itself writes nothing there. What a plugin does on its own is its business;docs/cli.mdsays so.Verification
Local, Python 3.12:
coverage run -m pytest -m 'not mongodb', without the integration test files: all passed. The one missed line offoca/foca.py(281,register_mongodb()increate_indexes()) is only reached by a test needing MongoDB, which CI runs.ruff check,ruff format --check,mypy,ast-grep scan,mkdocs build --strict: passed.db, and also covers adbsection withcreate_indexes_on_startup: true.CI: see the checks of this PR.
Declined review findings
db.Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Prevent read-only CLI checks from performing gateway plugin store setup while preserving normal startup and index-creation behavior.
Bug Fixes:
Enhancements:
Documentation:
Tests: