Align OpenAI telemetry with the configured Codex worker session (#171) #172

Merged
adrian.tkacz merged 2 commits from fix/171-openai-status-worker-session into develop 2026-10-04 18:51:10 +00:00
Member

Summary

Closes #171.

make codex-login authenticated the worker's isolated source home while plain scarcity-router status inherited an unrelated ambient CODEX_HOME, producing unknown/telemetry_unknown. The shared CLI/MCP/REST collector now discovers the same installed-service source as login.

  • Automatically use the existing controlled home when exactly one Codex source is configured; preserve ordinary local collection without a service/source.
  • Add explicit configured-source selection and SCARCITY_ROUTER_CODEX_SOURCE=@local; fail safely on ambiguity, invalid configuration and unsafe/missing homes.
  • Preserve SCARCITY_ROUTER_CODEX_BIN precedence; share worker/login discovery and validate service-derived binary pins consistently.
  • Keep credentials provider-managed and pass the home only in the child environment. No credential copying, home provisioning, global environment changes, inference, or serialized contract changes.
  • Move existing home/discovery/state-path helpers only to avoid import cycles; document source precedence in D-067 and add deterministic regression tests. The provisioning guardrail replaces the old helper module with its new location, without expanding allowed writes.

CI Fixture Follow-Up

Commit 59ec469 changes only tests/test_worker_local_store.py. The existing foreign-owner test displayed UID 0 and assumed it was foreign; on the CI runner (effective UID 0), that is the current user's own directory, correctly accepted by production code. Reproduced the exact failure under UID 0 in a read-only, networkless container before editing.

The fixture now chooses an owner distinct from the effective user: UID 1 under root, UID 0 otherwise. It still requires ownership rejection and an empty directory afterward; its exact diagnostic assertion accepts the existing general-component or final-owner refusal. No production/security checks changed, no new skips or permissive mode were added.

Validation

  • uv sync --only-dev
  • Latest umask 0022 && make check: 2674 tests run, OK, 15 skipped; basedpyright zero errors/warnings.
  • Additional uv run basedpyright and git diff --check: pass.
  • Worker-local-store module under real UID 0 in an isolated Python 3.12 container: 48 tests run, OK, 16 existing skips. Same module as a non-root user: 48 tests run, OK, 15 existing skips. The reported failing test executes and passes in both contexts.
  • Installed ordinary-shell status on Precision was verified healthy without a CODEX_HOME override after make install; no worker-service restart or credential copying.
  • Independent review, one blocker remediation, then narrow final verification: PASS. Reviewed production implementation is unchanged; the later CI correction is fixture-only.
  • Two issue-scoped commits (df6f758, 59ec469), no merge commits; clean local worktree. New remote CI outcome is not yet asserted.

Local validation uses umask 0022 because this host's ambient 0002 makes existing fixture homes group-writable, correctly rejected by unchanged security checks. Earlier full runs emitted an intermittent fixture-thread teardown ConnectionError: peer read failed at tests/worker_fixtures.py:226 while still passing; the latest full run completed without that traceback. Transport/fixture code for that separate diagnostic is unchanged.

UX / Compatibility

One successful make codex-login now serves normal status collection with no recurring home override. Existing local usage can opt out explicitly; ambiguous configuration gets an actionable error instead of another account's quota. CLI takes the installed fix immediately; already-running MCP/REST processes need their normal restart to load updated code. Independent UX verification found no material regression. CI fixture follow-up: UX impact none.

Human merge gate: leave this PR open for Adrian's review and merge into develop; no automatic merge or main promotion.

Evidence: implementation/review checkpoint, narrow review PASS, local installation/final validation.

## Summary Closes #171. `make codex-login` authenticated the worker's isolated source home while plain `scarcity-router status` inherited an unrelated ambient `CODEX_HOME`, producing `unknown/telemetry_unknown`. The shared CLI/MCP/REST collector now discovers the same installed-service source as login. - Automatically use the existing controlled home when exactly one Codex source is configured; preserve ordinary local collection without a service/source. - Add explicit configured-source selection and `SCARCITY_ROUTER_CODEX_SOURCE=@local`; fail safely on ambiguity, invalid configuration and unsafe/missing homes. - Preserve `SCARCITY_ROUTER_CODEX_BIN` precedence; share worker/login discovery and validate service-derived binary pins consistently. - Keep credentials provider-managed and pass the home only in the child environment. No credential copying, home provisioning, global environment changes, inference, or serialized contract changes. - Move existing home/discovery/state-path helpers only to avoid import cycles; document source precedence in D-067 and add deterministic regression tests. The provisioning guardrail replaces the old helper module with its new location, without expanding allowed writes. ## CI Fixture Follow-Up Commit `59ec469` changes only `tests/test_worker_local_store.py`. The existing foreign-owner test displayed UID 0 and assumed it was foreign; on the CI runner (effective UID 0), that is the current user's own directory, correctly accepted by production code. Reproduced the exact failure under UID 0 in a read-only, networkless container before editing. The fixture now chooses an owner distinct from the effective user: UID 1 under root, UID 0 otherwise. It still requires ownership rejection and an empty directory afterward; its exact diagnostic assertion accepts the existing general-component or final-owner refusal. No production/security checks changed, no new skips or permissive mode were added. ## Validation - `uv sync --only-dev` - Latest `umask 0022 && make check`: 2674 tests run, OK, 15 skipped; basedpyright zero errors/warnings. - Additional `uv run basedpyright` and `git diff --check`: pass. - Worker-local-store module under real UID 0 in an isolated Python 3.12 container: 48 tests run, OK, 16 existing skips. Same module as a non-root user: 48 tests run, OK, 15 existing skips. The reported failing test executes and passes in both contexts. - Installed ordinary-shell status on Precision was verified healthy without a CODEX_HOME override after `make install`; no worker-service restart or credential copying. - Independent review, one blocker remediation, then narrow final verification: PASS. Reviewed production implementation is unchanged; the later CI correction is fixture-only. - Two issue-scoped commits (`df6f758`, `59ec469`), no merge commits; clean local worktree. New remote CI outcome is not yet asserted. Local validation uses umask 0022 because this host's ambient 0002 makes existing fixture homes group-writable, correctly rejected by unchanged security checks. Earlier full runs emitted an intermittent fixture-thread teardown `ConnectionError: peer read failed` at `tests/worker_fixtures.py:226` while still passing; the latest full run completed without that traceback. Transport/fixture code for that separate diagnostic is unchanged. ## UX / Compatibility One successful `make codex-login` now serves normal status collection with no recurring home override. Existing local usage can opt out explicitly; ambiguous configuration gets an actionable error instead of another account's quota. CLI takes the installed fix immediately; already-running MCP/REST processes need their normal restart to load updated code. Independent UX verification found no material regression. CI fixture follow-up: UX impact none. Human merge gate: leave this PR open for Adrian's review and merge into `develop`; no automatic merge or main promotion. Evidence: [implementation/review checkpoint](https://forgejo.creatidy.com/BioMedical-IT/scarcity-router/issues/171#issuecomment-13606), [narrow review PASS](https://forgejo.creatidy.com/BioMedical-IT/scarcity-router/issues/171#issuecomment-13607), [local installation/final validation](https://forgejo.creatidy.com/BioMedical-IT/scarcity-router/issues/171#issuecomment-13608).
Align OpenAI telemetry with the configured Codex worker session (#171)
Some checks failed
ci / check (pull_request) Failing after 9m10s
df6f758ff4
adrian.tkacz approved these changes 2026-10-04 17:13:52 +00:00
Dismissed
Fix foreign-owner fixture for root CI runners (#171)
All checks were successful
ci / check (pull_request) Successful in 9m38s
59ec4690e7
adrian.tkacz deleted branch fix/171-openai-status-worker-session 2026-10-04 18:51:11 +00:00
Sign in to join this conversation.
No description provided.