One-command make codex-login reading the configured source from the installed worker unit (#168) #169
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
P1
P2
P3
question
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Creatidy/scarcity-router!169
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "task/168-codex-login-make-target"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #168 (kept open for human review; do not merge without the owner's approval).
What
One identical command on every host refreshes the local worker's Codex credentials:
No
.dev/.prdvariants, no host-specific arguments, no source id typed by the operator.How the local Codex source is discovered
The persisted home of the operator's adapter selection is the generated systemd user unit itself (D-065:
service install --codex-source <id>renders it intoExecStart). This PR adds an exact read-back inworker_service.py:parse_exec_start(value)invertsrender_unit's rendering layer by layer (the:no-substitution prefix, systemd word quoting,%%specifier unescaping) and validates the generated shape (<executable> run --state-dir <dir>plus the selection flags);read_installed_service_configuration()reads the installed unit, gated on the generated marker line — a missing unit, a foreign unit, an unknown flag, a wrong shape or a dangling value refuses with the remediation recipe (service install --codex-source SOURCE_ID), never a guess;scarcity-router-worker codex-loginwith--sourceomitted requires exactly one configured--codex-source(zero or several → actionable refusal listing the ids) and passes the discovered source, the unit's--state-dirand its pinned--codex-binthrough. Explicit flags keep their exact prior semantics; discovery only fills what was omitted.What is reused (nothing new invented)
scarcity-router-worker codex-loginmachinery andrun_official_codex_login— the officialcodex login --device-authflow against the source-controlledCODEX_HOME(<state_dir>/codex-sources/<source_id>/, D-053).--state-dir), so the login addresses exactly the controlled home the running worker probes.~/.codexis never read, copied or adopted.Worker restart
Not required: the Codex adapter re-probes account auth from the controlled home on every eligibility check, so the running worker picks up the fresh credentials on its next check.
Verification
make checkgreen: 2649 tests OK (15 skipped),uv run basedpyright0 errors / 0 warnings;git diff --checkclean;origin/develop..HEADcontains only this change (single commit7430d89).ExecStartReadBackTests(9 — exact round-trip with hostile paths, agreement with the independentsystemd_wordsoracle, marker gating, missing/foreign unit, unknown flag, wrong shape, dangling value, multi-source order, Ollama+ZCode selection preservation) andCodexLoginDiscoveryTests(6 — discovery passes source/state-dir/bin, explicit--sourcekeeps exact prior semantics, no-source refusal with recipe, ambiguous-source refusal, missing unit, foreign unit).make helplists the target;make -n codex-loginprints the singleuv run scarcity-router-worker codex-loginline; reading the actual installed unit resolvesstate_dir=/home/adrian/.local/share/scarcity-router/workerand zero configured codex sources — the command refuses with the install recipe (correct: the ROG service currently runs without a Codex source; afterservice install --codex-source <id>+service restartthe same command resolves it).--codex-source precision-codex-live(the documented install form); the exact flag shape — including the source id, state-dir pass-through and quoting — is covered by the round-trip and discovery tests against the samerender_unitoutput.scarcity-router-worker codex-loginpath (verification points 3–6: controlledCODEX_HOMEpreserved,~/.codexuntouched, no second install/store — by construction of the reused machinery, negative-scanned by the existing suites).UX impact
The user-facing consequence is the feature: refreshing credentials drops from "know and type the host-specific source id" to
make codex-login. First-run on a host without a configured source prints the exactservice install --codex-source SOURCE_IDrecipe; a multi-source host is told to pass--sourcewith its ids listed. No error path is silent; no secret is printed (the unit embeds none).Review dimension checklist
codex-login --sourcebehavior unchanged; no serialized contract, protocol, catalog or selector change.docs/decisions.md.make codex-loginthat refreshes the local worker's Codex credentials #168make codex-loginthat refreshes the local worker's Codex credentials #168