feat(cli): apply shared daemon write-routing policy - #2033
Conversation
d6be94a to
e460799
Compare
|
Restacked this PR onto current The rebase completed without conflicts. The branch now contains exactly one PR-specific commit: the routine CLI-routing implementation. The shared routing-policy foundation from #2027 and the hook-routing implementation from #2030 are inherited from Post-restack validation:
CI reran against the restacked branch and is green. |
|
Thanks for this contribution, and apologies for the slow turnaround.
If you'd rather not pick it back up, no problem at all — just say so and I'll close it out, and thanks either way for taking the time to send it. |
|
I will fix it and make it ready @igorls |
e460799 to
b6ed0df
Compare
|
@igorls rebased this branch onto current The rebased branch remains one PR-specific commit and preserves current
The shared routing policy now applies to the intended routine CLI
Post-init daemon mining continues to use the already scanned file list The daemon service now supports sweep jobs for both transcript files and The pre-scanned-file daemon payload is validated before mining:
Validation completed:
The PR-specific diff remains limited to the CLI-routing implementation, The rebased history was pushed with |
What does this PR do?
Dependency
What does this PR do?
Builds on the shared routing-policy foundation merged in #2027 and the hook-routing implementation merged in #2030.
Contributes to #1963.
This is the third PR in the staged hook and CLI gateway rollout.
It applies the shared
direct/prefer/requirepolicy to routine CLI write operations:mempalace mine;mempalace sweep;mempalace sync;mempalace init.It also makes
sweepa first-class daemon job and preserves the one-time project scan performed byinitwhen that mine is submitted to the daemon.Policy behavior
directUse the existing direct in-process execution path.
preferSubmit through the local daemon.
Interactive CLI commands are allowed to start the daemon if it is not already running.
requireSubmit through the local daemon.
Interactive CLI commands are allowed to start the daemon if it is not already running.
Because CLI commands can start the daemon, both
preferandrequirenormally select it. The distinction remains important for hook callers, which cannot safely cold-start the daemon.Explicit overrides
Force daemon routing:
Force direct execution:
The options are mutually exclusive and override environment/config policy.
The same options are available for:
init;mine;sweep;sync.Background jobs
--backgroundnow follows the selected route rather than requiring the literal--daemonflag.For example, this works when CLI routing is configured as
preferorrequire:A direct route with
--backgroundexits with an explicit configuration error.No ambiguous fallback
Once daemon submission begins, an error never causes the command to rerun directly.
The daemon may have durably accepted the job before the client observed a timeout or transport failure. Retrying the operation directly could duplicate memories or race the accepted job.
Post-init mine
mempalace initalready scans the project once to show the user a file-count and size estimate.When the accepted mine is daemon-routed, this PR forwards that exact scanned file list in the daemon payload. The daemon therefore does not need to walk the project a second time.
Sweep support
Before this PR,
sweepwas direct-only.This PR adds daemon service support for:
Backward compatibility and rollout
The default CLI policy remains
direct.Existing users therefore receive no silent execution-topology change.
A supervised Tier 3 deployment can opt in with:
or prohibit direct routing with:
Configuration file:
The production default can be reconsidered after the stacked rollout is reviewed and merged.
Maintenance exclusions
The following remain outside ordinary write routing:
These operations may replace indexes, rewrite broad metadata sets, or require cached handles to close. They need an exclusive-maintenance policy rather than an ordinary daemon queue job.
Safety properties
requirenever falls back to a direct writer.--directremains available as a deliberate emergency/debug escape hatch.--daemonremains backward compatible.mine_palace_lock().Tests
Coverage includes:
--daemonand--directprecedence;Run:
Rollout sequence
References
Contributes to the Tier 3 rollout in #1963.
Builds on #2027 and #2030, both merged.
Uses the daemon gateway direction from #1976 and #1270.
Related to #1888, #2002, #2026, and #2028.
How to test
Checklist
python -m pytest tests/ -v)ruff check .)