Skip to content

Persist the mode terc mode switches, and add terc core start|stop - #9

Open
pentaoa wants to merge 1 commit into
wormforce:mainfrom
pentaoa:cli/mode-persist-and-core-control
Open

pentaoa wants to merge 1 commit into
wormforce:mainfrom
pentaoa:cli/mode-persist-and-core-control

Conversation

@pentaoa

@pentaoa pentaoa commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

What

terc mode rule switched the running core but left config.yaml alone, so the
mode reverted on the next reload or restart. The TUI (cycle_routing_mode)
already calls persist_mode; the CLI now does the same, and reports
persisted in --json.

Headless runs also had no way to start or stop the managed core - the TUI
toggle was the only path - so terc core start|stop [--json] mirrors it.

Why it matters

The mode is carried into every regenerated config (compose::carry_runtime_state
keeps the old mode), so a single Direct written to the file survives every
restart. A scripted terc mode rule looked fixed until the core restarted, and
then everything went direct - which reads as "the proxy is broken".

Notes

  • terc mode still exits 0 when only the file write fails: the running core did
    switch. The warning goes to stderr and --json carries persisted: false.
  • terc core stop keeps the existing behaviour of releasing a system proxy that
    points at the core.
  • The change is platform-neutral; it was exercised on a Windows port of this
    tree, which is where the bug was reported from.

Testing

cargo fmt --check, cargo clippy --all-targets --locked -- -D warnings,
cargo test --all-targets --locked (340 passed).

The TUI writes the mode it switches to back into config.yaml (main.rs
cycle_routing_mode), because a reload or a core restart applies the file's
mode. The CLI only PATCHed /configs, so a scripted `terc mode rule` reverted
to whatever the file held on the next restart - the failure looks like "the
proxy works until the core restarts".

`terc core start|stop` gives the same headless control the TUI has, so a core
can be brought up (or taken down, which also releases a system proxy pointing
at it) without an interactive terminal.
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