Skip to content

[P1][LM-3] Run Codex against isolated local connection profiles #379

Open

Description

@BunsDev

Outcome and dependencies

Connect local selections to the existing native Codex backend while isolating connection configuration, process lifetime and session authority.

Parent: #376. Blocked for completion by: #377 (LM-1 contract/native feasibility) and #378 (LM-2 validated connection/credential/discovery service). Delivery group: Local models v1 / Gate B. Priority: P1. Follow the shared execution contract in #376. Dependencies mean accepted artifacts, not unrelated issue closure.

Context and source entry points

Refresh main, scoped AGENTS.md and open PRs. Publication baseline: ec7be578765f9ce54976882853e57ca190252361; retain newer native lifecycle and companion fixes. Existing: apps/desktop/src/main/engine/{runner,store}.ts, apps/desktop/src/main/engine/backends/{codex,types,health}.ts, apps/desktop/src/shared/types.ts. Proposed: apps/desktop/src/main/engine/local-models/{codex-profile,backend-pool}.ts, apps/desktop/test/local-codex.test.ts. Extract only focused code needed for profile selection; no broad runner rewrite.

Consumes: accepted target/provenance contract and validated private connection snapshot. Produces: connection-scoped native backend acquisition, effective configuration, safe session binding and lifecycle observations consumed by policy/UI/qualification work. One integrator owns shared runner/backend changes.

Implementation steps

  • Generate validated per-child Codex configuration through the existing constructor args/env/redaction seam. Use nonreserved provider identifiers where custom definitions are required. Gate configuration against the installed CLI schema; never shell-interpolate model IDs, credentials or URLs.
  • Keep coding execution in codex app-server. Modex may discover bounded metadata but must not POST coding prompts directly to an inference server. Use a local model catalogue mechanism only when the installed app-server needs it; capture that requirement in evidence.
  • Replace singleton assumptions only where necessary with lazy native instances scoped by connection revision, credential/account generation and effective process-level configuration. Include model settings in the instance key when the CLI cannot vary them safely per thread. Expose normalized service identity for shared capacity accounting; do not introduce a general scheduler here.
  • Bind each turn and resume handle to immutable connection/model/runtime provenance. Old cloud threads retain cloud identity. Endpoint, credential or profile-generation changes cannot silently resume against another provider. Require an explicit new native session while preserving historical UI content; never automatically replay a prior prompt/tool after uncertainty.
  • Audit inherited configuration, managed policies, auth, redirects and proxy/environment precedence. Verify the effective native inference destination, including loopback proxy bypass and redirect handling. Metadata endpoint validation alone does not constrain native requests. Never edit ~/.codex/config.toml or shell startup files and never evade managed policy through an isolated home. Unsupported policy/configuration must fail with an actionable reason.
  • Preserve native approvals, sandbox modes, observations, tool results, Stop and request delivery. Normal Stop stays turn-scoped. Force-stop is limited to its native instance with affected threads disclosed; never terminate the user's inference daemon or an unrelated cloud/local instance.
  • Send effort, reasoning-summary, fast-tier, vision and tool settings only when supported. Coordinate native-plan/collaboration presets so they cannot override the selected local target. Local readiness must not require paid cloud-model login; failed local targets must never select cloud models.

Acceptance criteria

  • AC1: a selected local model completes a real tool/edit/test fixture through the existing app-server adapter without cloud-model authentication.
  • AC2: simultaneous cloud/local profiles share neither credentials nor resume handles/effective provider configuration; stopping one does not terminate an unrelated instance.
  • AC3: profile edits, credential rotation and process restart cannot rebind a saved session silently or replay an uncertain action.
  • AC4: existing cloud/native regression tests pass and global user configuration bytes remain unchanged.
  • AC5: unsupported options are omitted or explicitly rejected; tool success and interrupted/unknown states come from native observations rather than assistant prose.
  • AC6: inherited config, proxy/redirect and native-plan override cases either retain the validated local target or refuse safely. No managed-policy bypass or secret leakage enters logs/renderer state.

Verification and handoff

Start with failing configuration/isolation/session tests; use real app-server acceptance separately from fixtures. Run current focused tests plus pnpm build && pnpm test; UI changes also pnpm test:e2e. Capture full SHA, native/runtime/model/configuration versions, request/process counts and side-effect evidence. Keep original failure logs redacted, update status and dated review evidence. No unapproved download, merge or release.

Long-running goal prompt

Implement LM-3 for TypeSafeAI/modex under #376 using #377/#378's accepted artifacts. Read current AGENTS.md, source and open PRs; verify main and your owned worktree. Begin with configuration, instance-isolation and resume-binding tests, then the smallest real local turn. Use the existing Codex configuration seam and ThreadRunner. Keep cloud instances unchanged, scope process lifetime correctly, audit native config/proxy/redirect precedence and prevent presets from overriding the local target. Preserve approvals, sandbox policy, events and Stop. Refuse unsupported configurations instead of adding an API executor. Work one acceptance slice at a time, run targeted/full checks, update status/evidence and make signed reviewable commits. Checkpoint SHAs, versions, actual results, remaining gates and one next step. No merge, release, global settings changes or unapproved downloads.

Follow-up / resume prompt

Resume LM-3 from live issue/PR evidence and its checkpoint. Verify ownership and actual diff; recheck #377/#378 contracts, connection revisions, actual process keys and saved-session provenance. Test cloud/local concurrency, connection edits, credential rotation, native-plan settings and Stop before continuing. Diagnose failures without relaxing sandbox policy or repeating uncertain tool actions. Preserve native event mappings and global user settings. Rerun smoke/full checks, record exact versions and fresh criterion-level evidence, and leave unrun native/human gates explicit. No merge, publication or architecture expansion.

Activity

  1. self-assigned this
    on Oct 22, 2026
  2. BunsDev commented on Oct 23, 2026

    @BunsDev
    ContributorAuthor

    Refreshed goal prompts — 2026-10-23 (main at 203a350)

    On main already:

    • nothing from LM-3. The runner and Codex backend have no local connection profile or provenance;
    • Codex Plan mode now runs in Codex's native plan collaboration mode (Run Plan mode on Codex in Codex's native plan collaboration mode (CF-3) #385). Its collaborationMode.settings model overrides the turn-level model, so a local run has to pin both and must refuse when no local model is selected.

    Still open:

    Leftover local worktrees: lm3-isolation (unpushed 665c095) and lm-foundation (untracked review and design docs only).

    Long-running goal prompt

    Do LM-3 (#379) in TypeSafeAI/modex under tracker #376. Read AGENTS.md, #376's shared execution contract, this issue, the LM-1 receipt on lm1-contract, PR #386 and docs/reviews/2026-10-22-lm3-prerequisite-audit.md on lm3-isolation. Then verify main's SHA. Never edit the primary checkout. Before you touch runner, backend or shared type files, agree with Val on #376 who integrates them. If you resume lm3-isolation, claim it with scripts/worktree.sh claim lm3-isolation --owner <session> and run check. Do not start until #377 and #378 have accepted SHAs. Consume those artifacts and do not write a third identity type. Slice 1: write failing tests first. Per-child Codex config built through the existing constructor args, env and redaction seam, with no shell interpolation. Native instances keyed by connection revision, credential generation and effective process settings. Saved sessions bound to immutable provenance, so a profile edit, credential rotation or restart cannot silently resume against another provider or replay an uncertain action. Slice 2: make #385's collaboration-mode model and the turn model both carry the pinned local target. Refuse when it is missing, and never fall back to a cloud or default model. Slice 3: audit inherited config, auth, proxy and redirect precedence for the native child. Refuse unsupported configurations. Never edit ~/.codex/config.toml or shell startup files, and never bypass managed policy. Slice 4: only with Val's authorization, run a real local tool, edit and test fixture through codex app-server with no cloud login. Run it next to a cloud thread and show that Stop on one leaves the other alone. Coding turns stay inside the codex CLI; add no API executor. Run pnpm build && pnpm test, plus pnpm test:e2e if the UI changes. Show that global CLI config bytes are unchanged. Update docs/local-models.md, docs/status.md and a dated docs/reviews/ receipt. Open signed PRs that link #379 and wait for Val's go-ahead to merge.
    

    Follow-up / resume prompt

    Resume LM-3 (#379). Confirm you own the worktree, fetch main and read the latest comments here, on #376, #377 and #378. Check whether LM-1 and LM-2 now have accepted SHAs and whether anything new touches codex.ts or runner.ts. Re-run the Codex, account and runner tests and the local isolation tests. Test cloud and local running together, a connection edit, credential rotation, native Plan settings and Stop before going further. Don't relax the sandbox or repeat an uncertain tool action to get past a failure. Post a checkpoint: SHA, codex-cli and runtime/model versions, results, what's left for a human, and one next action.
    
  3. BunsDev commented on Oct 26, 2026

    @BunsDev
    ContributorAuthor

    Checkpoint 2026-10-26 — PR #417, branch lm3-codex from main deb373a; commits 2460ec5 (implementation and tests) and 7ca83db (docs), SSH-signed.

  4. BunsDev commented on Oct 27, 2026

    @BunsDev
    ContributorAuthor

    Checkpoint 2026-10-27: #417 (lm3-codex) is rebased on main 6c9000f at 9159eda with the two review findings repaired (product admission closed until AC6 is qualified; no reasoning-summary option for a local child). #419 (lm5-policy, stacked on #417) qualifies the AC6 remainder: effective-configuration admission through Codex's own config/read/configRequirements/read with managed, project and dirty-home layers refused by name, a model/rerouted refusal, and real-CLI redirect evidence (body follows a 307, token never does; recorded, not preventable). Evidence: docs/reviews/2026-10-26-lm3-local-codex.md#review-repair-2026-10-27 and docs/reviews/2026-10-27-lm5-destination-policy.md. Still open: AC1 live turn (Val), a live managed-policy run, and the decision to wire LocalExecution into main.

  5. BunsDev commented on Nov 12, 2026

    @BunsDev
    ContributorAuthor

    AC1 and AC4 now have applicable evidence on protected main 5f1f1fe8bfa93ee971de7b443f794335ae9c414e. Its tree is exactly the native-tested 2bd27e068003bc7306645f56dab368ab66399594 from head 7d2d6c89de5a262d08876777a907568acd4a4405; the source diff is empty. The earlier receipts are no longer branch-only.

    AC1’s real native-adapter fixture used Codex 0.167.0 and the already authorized local Qwen coding model through the existing codex app-server adapter. It recorded three matching native tool starts/succeeded outcomes: a read, an explicitly approved edit and an explicitly approved independent check. Retained literal files contain the expected edit bytes and exactly one successful check effect. The private child excludes cloud authentication. The same kernel boundary applies to client and owned server, with external-network/outside-write denial controls. Native receipt and limits.

    For AC4, protected queue run 43127440657 passed 2,471 units with 36 skips, 514 desktop E2E cases with eight skips, and seven site cases, with zero failures/cancellations. The native workflow records identical personal configuration SHA-256 and modification time before/after, plus unchanged synthetic configuration bytes/tree. Independent review and a fresh root recheck verified all 14 original evidence hashes and all 13 non-controller archive files. The archive’s controller is the documented pre-finalization snapshot; the external canonical terminal receipt supplies final state. Raw CLI session files were removed by normal disposal and are not claimed as retained evidence.

    Only AC1 and AC4 are being ticked. AC6 remains open: the retained native 307 fixture forwards the coding body to another endpoint while withholding the token, which does not meet selected-destination retention or safe refusal; live managed-policy acceptance is also unrun. Existing simultaneous cloud/local isolation claims retain their fixture scope. Normal product execution remains unadmitted, and this update grants no activation or broader compatibility approval. Issue #379 stays open.

  6. BunsDev commented on Nov 12, 2026

    @BunsDev
    ContributorAuthor

    Current-version AC6 diagnostic: the installed Codex 0.167.0 still follows a 307 from the configured loopback endpoint to a second endpoint with the coding body. The existing canonical redirect fixture was run once normally and once under the existing loopback-only kernel policy; these were separate boundary cases, with synthetic servers, prompt and token, no model and no inference. Each diagnostic passed because it asserts the observed forwarding behavior; that result records an unmet selected-target invariant.

    Under the kernel boundary, server A and server B each received a POST to /v1/responses carrying 29,109 bytes and the synthetic prompt. Only A received bearer authorization. The 302 case reached B as a bodyless GET. Both native turns completed using B’s answer. Before the test, worker 8839 recorded EPERM for the external-TCP and outside-write controls. The policy permits localhost:*, so those denial controls do not bind inference to the selected loopback endpoint.

    Independent review and root rehash verified the retained request, boundary, source and terminal artifacts. Personal configuration SHA-256 and modification time were unchanged within this run. All five sampled processes later returned ESRCH, and all four fixture ports returned ECONNREFUSED; this is sampled cleanup evidence, not exhaustive descendant discovery. The native CLI inherited the outer policy; only the actually emitted Node worker receipt is claimed.

    AC6 remains open, and production execution stays unadmitted. Any repair must address the validated target itself rather than relying on external-TCP denial or token withholding alone. The current official provider configuration reference does not document a per-provider redirect switch; that documentation check alone does not prove the absence of every native capability. No product source, activation or acceptance checkbox changed for this diagnostic.

  7. BunsDev commented on Nov 13, 2026

    @BunsDev
    ContributorAuthor

    Current LM-3 diagnostic checkpoint on macOS 27.2.1 arm64 with actual Codex CLI 0.167.2: the destination guard is still unqualified, and AC6 remains open. No product admission, activation or checkbox change follows from these probes.

    A localhost port-only Seatbelt rule does not pin the address family: a native 307 redirect can send the same request body from selected IPv4 loopback to IPv6 loopback on the same port. An IPv6-only socket-family rule also permits an IPv4-mapped loopback redirect. Byte digests and server-side connection/received-byte observations are retained; these are not packet-capture claims. Literal numeric-IP syntax was refused by the sandbox compiler rather than treated as a working guard.

    An IPv4 socket-family outbound rule blocks the tested same-port IPv6 redirect and permits a narrow native read after explicit single-command approval. However, that read did not establish native workspace-sandbox compatibility. The subsequent controlled comparison preserves native workspaceWrite policy and declines every approval/escalation: the unwrapped native fixture edit succeeds, while the same edit beneath the outer Seatbelt fence returns native tool exit code 71 with sandbox-exec: sandbox_apply: Operation not permitted. The fixture remains unchanged. The scripted assistant can still complete its reply after that tool failure, so turn completion is explicitly not counted as a successful edit. Read-approval denial was independently preserved both with and without the fence.

    The first mode-control attempt timed out during unwrapped app-server startup before any request; that first failure is retained and unexplained. A bounded startup-capture follow-up reached all four comparisons, and a further two-case output capture isolated the native tool error above. Real CLI configuration bytes/mtime remained unchanged; originals and byte-verified copies are retained. All six recorded native children from the captured comparisons were sampled absent afterward, and all twelve corresponding IPv4/IPv6 address probes refused connections.

    The existing offline qualification boundary explicitly supplies a declared host boundary for its private canary. That is a separate scope. It does not justify labeling a network-only product wrapper as a native-equivalent filesystem sandbox. No externalSandbox override was added to these comparisons, no native approval was relaxed, and no proxy/API inference executor, paid inference, real model/server or managed-policy change was used. The next implementation must prove supported destination binding together with the required native mode/filesystem/approval behavior; managed-policy, runtime/offline-server, Stop/resume and admission gates remain open.

  8. BunsDev commented on Nov 13, 2026

    @BunsDev
    ContributorAuthor

    LM-3 native boundary follow-up: the trusted OS-helper experiment repairs the earlier Agent-mode sandbox_apply failure, but it cannot be admitted as the product solution. An independent review identified a Full Access path around its executable-wide exemption; a bounded actual Codex 0.167.2 control confirmed it. With the parent fence alone, a synthetic tool attempting to replace its sandbox fails with exit 71 and the unselected loopback endpoint receives zero connections/bytes. With the helper exemption, the same Full Access tool supplies a permissive profile and POSTs the 33-byte owned sentinel to the owned same-port IPv6 endpoint, without bearer credentials. This is a Full Access counterexample, not an unapproved default Agent escape or evidence of the inference client redirecting.

    The broad helper exemption is rejected for product use. Supported native modes and approval/escalation semantics remain requirements; they are not removed to make the experiment pass. AC6 remains unticked. The earlier invalid Python control is retained and excluded, and the prior eight-case packet's missing pre-execution generated-module identity remains a provenance limitation. The new counterexample records 443 generated-file hashes before/after at clean source 249154d57f7f4f849b79f87ea0fd259768ce6a86; these do not retroactively bind the earlier packet.

    This used only synthetic private fixtures and loopback responders, with no real model, paid inference, personal credential, external endpoint, product wiring or admission. Both sampled native PIDs were absent and all four post-run address probes refused connections; personal Codex configuration bytes/mtime stayed unchanged. The full mode, approval/permission, managed policy, identity/race, Stop/process-tree, runtime and genuine offline qualification gates remain open. The next implementation needs an enforceable destination boundary that preserves the native execution contract.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:local-modelsenhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions