Repository navigation
Description
Outcome and dependencies
Apply one local-run policy across the main turn and auxiliary work, while handling limited context/hardware without cloud fallback or duplicated actions.
Parent: #376. Blocked for completion by: #377 (LM-1 contract) and #379 (LM-3 scoped native execution/identity). Delivery group: Local models v1 / Gate B. Priority: P1. Follow the shared execution contract and privacy invariants in #376. This policy is required before the integrated local UI is considered complete; producers do not depend on final acceptance.
Context and source entry points
Refresh current main and scoped instructions; publication baseline ec7be578765f9ce54976882853e57ca190252361 is historical evidence only. Existing: apps/desktop/src/main/engine/runner.ts and the routing, title/follow-up, routine, plugin/MCP, companion and recovery owners identified in #377. Reuse #273/#276/#279's current identity/request/replay contracts and #373's delivered phone broker path. Proposed: apps/desktop/src/main/engine/local-models/run-policy.ts, apps/desktop/test/local-run-policy.test.ts. Extend existing admission/request/replay infrastructure; no general scheduler or parallel policy broker.
Consumes: immutable target/service identity and native lifecycle from #377/#379. Produces: main-owned local policy/admission decisions, context validation, cancellable per-service capacity and truthful recovery results for UI and runtime qualification.
Implementation steps
- Make no-cloud-inference-fallback a main-process invariant covering timeouts, unavailable models, credit fallback, Auto, titles, follow-ups, compaction and delegated work. Disable automatic auxiliary model calls in v1 when they cannot be safely bound; use deterministic titles and no automatic model-generated follow-ups.
- Keep Jev network routing/approval calls off for local-only runs; retain deterministic rules and explicit human decisions. Disable remote web search, remote MCP and unqualified plugin paths by default. Separately authorized network tools must be visible and must not relax the inference target. Audit native child config, not just renderer switches.
- Distinguish approved loopback endpoint, locally executed inference and offline verification. Reject known cloud-routed models; unknown downstream routing stays unverified. Document account/update traffic separately. A loopback check or coding-tool sandbox does not constrain an externally launched inference service.
- Use runtime effective context where available. Show advertised maximum, actual configuration and user override separately. Do not inherit a cloud-model context default; where a value is necessary, require runtime evidence or an explicitly recorded validated override. Unknown counts stay unknown. Native compaction must stay local; long prompts/tool outputs must not drop policy or tool-result linkage silently.
- Default to one active Modex inference run per normalized local service, including relevant auxiliary work. Profiles targeting the same service share capacity. Disable unqualified native parallel subagents: one parent turn alone does not bound internal inference concurrency. Reuse a small queue/semaphore with cancellable waiting and explicit status. Do not claim limits on work started by other applications.
- Handle cold start, missing model, OOM, context overflow, invalid tool output, disconnect and interrupted actions with actionable states. Stop/replay must not dispatch more actions. Never automatically retry an ambiguous coding turn, switch model after partial edits or turn unknown execution into success.
- Enforce the same policy at desktop IPC, paired-desktop/phone, routine and background admission points. Older clients get truthful non-actionable fallback. Unsupported unattended local workflows stay unavailable rather than being rerouted to a cloud target.
Acceptance criteria
- AC1: network spies/fixture sinks observe no cloud inference, Jev, remote compaction or implicit auxiliary disclosure for local-only turns, including every failure path.
- AC2: each combination claimed offline completes a pre-provisioned network-denied native coding smoke covering both Modex and the inference service. Unrun combinations remain unverified.
- AC3: two profiles addressing the same service honor Modex capacity; cancelling a queued run sends zero inference requests. Unqualified subagents cannot escape admission/destination policy.
- AC4: overflow/OOM/restart/Stop yields truthful failed/interrupted/unknown outcomes without silent fallback, lost policy or duplicate tool execution.
- AC5: main validates local-only policy for companion/routine/background entry points; forged or stale clients cannot relax it.
- AC6: effective-context evidence/override is recorded; unknown values and network-locality limits remain explicit in diagnostics rather than fabricated.
Verification and handoff
Write red/green tests for auxiliary leakage, fallback, uncertain retries, context, same-service concurrency and queued cancellation. Run focused suites and pnpm build && pnpm test; UI changes also pnpm test:e2e. Native network-denied canaries require explicit authorization and preinstalled artifacts. Record exact SHA/configuration, observed requests/side-effect counts, genuine OS/runtime constraints, failures/skips and one next action in issue/PR and dated review evidence. No merge/release or external runtime termination.
Long-running goal prompt
Implement LM-5 for TypeSafeAI/modex under #376 after consuming #377/#379's accepted contracts. Read current AGENTS.md, live source and open PRs; verify main and owned worktree. Trace every auxiliary inference/network and admission path. Implement a main-owned local-run policy, not a new executor: pin or disable each path, retain deterministic/human approvals and refuse unsupported automation. Begin with tests catching cloud fallback, Jev/title leakage, uncertain retries, small context and same-service concurrency. Bound local capacity without inventing a scheduler, and keep context/offline claims evidence-based. Run targeted/full checks, update status and evidence, and prepare signed reviewable commits. Checkpoint full SHAs, versions, exact results, remaining gates and one next step. No merge, release, global configuration rewrites or unapproved downloads.
Follow-up / resume prompt
Resume LM-5 from its live PR/issue and checkpoint. Verify ownership, actual diff and prerequisite contracts. Review newly landed code for fresh inference/network or companion/routine entry points before trusting old privacy evidence. Retest local failure paths, queued cancellation and Stop after a tool started. Repeat network-denied canaries only within existing authorization; reconcile any unknown prior side effect instead of resending. Repair the smallest failing criterion with a regression first, rerun smoke/full checks and record fresh evidence separately from mocks. Leave native/human gaps open. No merge, publication or scope expansion.
Activity
BunsDev commentedon Oct 23, 2026
Refreshed goal prompts — 2026-10-23 (
mainat203a350)On
mainalready:mainand run unchanged for every turn: Auto routing and the Jev judge, approval rules, titles and follow-ups, routines, the iPhone companion broker and credit fallback.Still open:
048d1e8onlm1-contract). LM-3 ([P1][LM-3] Run Codex against isolated local connection profiles #379) has an audit and no implementation. LM-5 needs LM-3's scoped native instances and service identity before it can enforce capacity or no-fallback on real runs.lm-foundationworktree (docs/superpowers/specs/2026-10-23-local-model-foundation-design.md) already lists the LM-5 requirements. They are admission at desktop, paired, routine and background entry points, one active inference per normalized service, unqualified subagents off, compaction and delegation coverage, recorded effective-context provenance, and local readiness that needs no paid cloud login. Val has not reviewed it.Long-running goal prompt
Follow-up / resume prompt
BunsDev commentedon Oct 27, 2026
Checkpoint — 2026-10-27, slice 1 delivered
Repo/worktree.
lm5-policy(owned by this session), stacked onlm3-codexat9159eda2f44b5d9a8705dbd6f2f797003b543be2(PR #417, rebased onmain6c9000f). Head:065447f99c18a0448f3f90ed3ecfd29ab7ffdb07. PR: #419 (baselm3-codex).Done (slice 1, destination and managed-policy admission; closes #379 AC6's open part).
engine/local-models/run-policy.ts:admitLocalConfigurationadmits a local child only when every governed key originates from Modex's session flags, no project layer is loaded, the private home is empty, no managed layer touches a governed key, no managed requirements apply, and the effective destination, wire, credential reference, context and tools are exactly what Modex passed. Refusals name the layer and key; nothing is rewritten.CodexBackendreadsconfig/read(with layers) andconfigRequirements/readbefore every thread open on a local child;LocalExecutionkeeps the admitted provenance. Amodel/reroutednotification fails the local turn.requirements.tomlis not read; a 307 from the configured loopback server is followed with the body and never with the token, a 302 as a bodyless GET. No Codex setting constrains redirects: recorded, not enforced. Evidence:docs/reviews/2026-10-27-lm5-destination-policy.md.Results. Focused suites 62/62; build and typecheck pass; full desktop unit suite 2,038 tests, 2,018 passed, 0 failed, 20 skipped (17 usual opt-in plus the three native LM-3/LM-5 checks); core/site/store/worktree suites pass; wire and redirect native tests pass. RED at LM-3's head recorded in the review.
Remaining gates. Live managed-policy run on a managed Mac; AC1 live turn (LM-3, Val); product wiring of
LocalExecution(Val's decision); AC2 offline canary (needs authorization and installed runtimes); AC5 entry points; AC6 context evidence; capacity across profiles and overflow/OOM/disconnect outcomes.One next action. After #417 lands and this PR retargets to
main: slice 2, a network-spy sweep of every auxiliary path (Auto/Jev, titles, follow-ups, routines, companion, background) for a local-only thread, failing-first.LM-5 slice 1: admit a local Codex child on its effective configuration (
LM-5: signed policy delivery and truthful reroute termination (#424)
docs: name #461 in the LM-5 status entry (#380)
BunsDev commentedon Oct 31, 2026
LM-5 checkpoint: context-window evidence landed (AC6)
#462 merged as
7eec3bf.mainstill constructs noLocalExecution, so product behaviour is unchanged.LocalModelDiscovery.advertisedContext(model)keeps what the runtime's last ready listing advertised for each model, by connection revision. It is null when the listing advertised none.LocalExecution.validaterefuses a window above a known advertised maximum before any process starts.context: { configured, source: "person", effective, advertised | "not-checked", loaded: "unknown" }.In the queue or in review:
Still needs Val:
LocalExecution.🤖 Generated with Claude Code
Refuse known cloud-routed and non-generative local models in main (#380)
BunsDev commentedon Nov 1, 2026
LM-5 admission brief: should main construct
LocalExecution? (for Val)This brief is current as of
mainat0a8c513plus PR #475 (in review, not merged). Nothing here changes product behaviour.main/index.tsstill constructs noLocalExecution, so a built app refuses every local selection and every persisted target. The decision and the change are yours.What main enforces before a local child opens or sends anything
by: "desktop", LM-5: fixture-level AC1 compaction, AC3, AC4 and AC5 (#380) #475). A paired desktop, the phone or a caller that names no client can't set, change or clear a target.LocalExecution.validaterequires all of the following. It runs on selection and again on every send, so a stale or forged persisted target ends the turn with a notice, never on cloud.NO_PROXY=*;MODEX_LOCAL_TOKEN, hidden from the tool shell;allowProviderModelFallback=false, and Codex must confirm both;.codexdirectory refused.config/readandconfigRequirements/readare read. They must show:request_max_retries=0and, new,stream_max_retries=0.model/reroutednotification fails the turn after native termination;Recorded, not preventable
unknown.Not run
MODEX_LM3_LIVE=1 MODEX_LM3_URL=… MODEX_LM3_MODEL=…).The exact change (I have not made it)
In
apps/desktop/src/main/index.ts, importLocalExecutionfrom./engine/local-models/execution.jsand add one option to thenew ThreadRunner({ … })call on line 242:Then invert
test/local-execution-wiring.test.ts, which today asserts that main doesn't wire it. Rollback is removing that line.Decisions for you
🤖 Generated with Claude Code
BunsDev commentedon Nov 1, 2026
LM-5 checkpoint: fixture-level AC1 compaction, AC3, AC4, AC5 (#475 in review)
main0a8c513; branchlm5-fixturesheadb6d1876; PR LM-5: fixture-level AC1 compaction, AC3, AC4 and AC5 (#380) #475.Results
AC1, compaction (wire). Three requests, all
POST /v1/responsesfor the selected model, with the bearer token:No other endpoint was requested. The compaction prompt and threshold keys are now governed.
AC3. Two profiles for one host and port share one slot. A stopped queued turn opened no child, and the recording server got 0 requests from it (1 request in total, from the first turn).
AC4 (wire). Seven modes. Each had 2 requests in total and 1 tool run, with no retry and no model switch:
Two repairs: a local 500 is no longer reported as Codex's cloud "high demand" text, and admission now requires
stream_max_retries=0. With retries on, Codex re-sent after a 500, a 503 and a dropped stream.AC5. Every entry point was traced (table in the review). The local-key filter was a deny-list for
paired-desktop; it's now an allow-list for this Mac's window. New cases cover the retry and saved-draft paths.[P1][LM-3] Run Codex against isolated local connection profiles #379 wire receipt on 0.166.0. Matches 0.164.0: same offered tools, token never in model input, and a 307 still followed with the body and without the token.
Tests.
pnpm build && pnpm testexit 0 (desktop 2,098 pass, 29 skip, 0 fail). Each new regression was red before its fix or under a negative control. Review:docs/reviews/2026-11-01-lm5-fixtures.md.Fixed: the stale "slice 1 on
lm5-policy" line indocs/local-models.md.Waits on Val:
Next action: once CI is green, Val reviews #475 and answers the admission brief.
🤖 Generated with Claude Code
LM-5: fixture-level AC1 compaction, AC3, AC4 and AC5 (#380)
docs: record the full-suite result in the LM-5 fixtures review (#380)
Narrow LM-5 fixture claims and report a notification-only local 500 t…
docs: record the LM-5 fixtures rebase onto b785054 (#380)
docs: add the LM-4 design brief and Val's local models decision record (
Admit local execution into the product runner (#380)
BunsDev commentedon Nov 11, 2026
Native continuation and completed compaction were observed on the current private-workspace trust repair, but action-safe compaction remains unqualified. Codex 0.167.0/Ollama 0.40.16 with the approved qwen3-coder:30b digest completed nine native turns under the network-denied boundary, including a completed compaction event and a following fixture read. Actual loaded context was 65,536; all 28 Responses requests returned HTTP 200. The candidate patch SHA256 stayed
d470000117cc8dfa0cc86e89d7e3b2c53a82c5ae5d3829dc3d45cdaf6a6bbf15, personal configuration and fixture bytes stayed unchanged, and all owned processes were independently confirmed absent afterward.The positive harness checked paired successful native reads but omitted an exact call-count assertion. Independent saved-session audit found 18 shell calls against 16 intended:
cat context-13.txtandcat context-14.txtwere each issued again after compaction within the same native turn. Native replacement history retained user messages and a summary, without function-call/output records; the summary said the files had already been read. This establishes repeated native read execution, not its root cause, a transport resend, or write-side replay safety. The audit therefore limits the raw harness pass to observed continuation; compaction safety and tool-result continuity acceptance stay open.The earlier dense-user-message attempt still records a post-compaction HTTP 400 overflow, and the separate 12-read attempt stopped below the compaction threshold. Neither is relabeled as a pass. The strict trust repair independently passed scoped review and real continuation; it can proceed toward protected delivery after remaining checks without claiming to resolve this compaction limitation. Fresh root build/typechecks and units passed (2,420 passes, 35 skips, zero failures); full Electron/browser E2E is running on the same frozen patch. Production local execution remains unadmitted; no acceptance box is ticked by this update.
Next: retain exact call counts in the qualification gate and investigate native replacement-history/tool-result continuity before admitting action-safe compaction. Preserve both the failed and limited-positive receipts, and require an actual no-duplicate action result before closing the corresponding acceptance criteria.
BunsDev commentedon Nov 11, 2026
Additional bounded diagnostics on signed candidate
5edbb84ee58921c191912c0575a317fe40805a62preserve the automatic compaction safety finding above. Using the same Codex 0.167.0/Ollama 0.40.16 and approved qwen3-coder:30b digest, a nativethread/compact/startrequested only after a completed read turn produced a completed compaction and a successful following fixture read. Independent saved-session audit counted exactly 14 intended and 14 observed read commands, eight completed read turns plus the native compaction turn, and 23 Responses requests, all HTTP 200. External TCP and outside writes were denied, actual loaded context remained 65,536, configuration and fixture bytes stayed unchanged, and observed owned processes stopped.A separate fresh network-denied read/edit/test canary on the same clean candidate also passed through
LocalExecutionand the installed CLI: one actual file read, the exact approved edit and one independently observed passing check, with three successful tool results and five Responses requests, all HTTP 200. The seeded check and input bytes were preserved by the canary assertions; the owned runtime logged a 65,536-token slot. Both Modex and the owned inference service were inside the denial boundary, and the personal configuration stayed unchanged. No model download or global configuration change was used.These are scoped observations, not a repair for automatic mid-turn compaction, write-side exactly-once execution or a general action-safety result. The earlier 18-versus-16 call result and HTTP 400 overflow remain retained; a single quiescent comparison does not prove their cause. Do not replace the failing automatic case with the passing idle diagnostic. Investigate native replacement-history/tool-result continuity and retain the strict call-count gate before admission. Protected delivery, OOM coverage, product decisions and remaining acceptance gates stay open; no checkbox or issue is closed by this update.
BunsDev commentedon Nov 11, 2026
The controlled counter probe on
5edbb84retained a limited positive approval result and a failing compaction-fidelity result. The saved native session contains 20 tool requests against 18 intended, including two distinctnode action-once.cjsrequests. The synthetic one-write approval callback allowed the first and refused the second before process creation; the counter recorded one actual effect. A separate control proved that two deliberate executions produce two effects, so fixture idempotence did not conceal a repeated write. This is test-actor evidence, not human acceptance.The original write turn completed before automatic compaction began in the following turn. The repeated request then appeared under a new native call ID in that following turn, whose new user input asked for different reads. Saved native inputs matched all ten submitted turns once. The raw harness pass checked the single effect; the stricter request-count audit failed. This does not qualify intra-turn action safety, agent-mode writes, general exactly-once behavior or product admission.
The version-matched upstream builder rebuilds local compacted history from retained user messages plus a summary; the captured summary explicitly said the action had already run once. This is consistent with the saved history, but does not prove whether request construction, runtime history handling or model behavior caused the repetition. Actual outgoing HTTP bodies were not captured. The automatic compaction gate remains open, and no checkbox or issue is closed by this update.
BunsDev commentedon Nov 11, 2026
A bounded transport observation on clean candidate
da13074cb764264df47e22ddc4ca732247d9ced9completed the same synthetic counter workload through native automatic compaction. Independent decoding of the retained raw bytes found 29 complete HTTP request/response pairs, all HTTP 200 with completed SSE responses. Exactly 18 model tool calls matched the 18 intended native calls, approvals and results, with one counter effect. The first observer attempt stopped before compaction because its connection-reset handling shut down the listener; that diagnostic failure was retained, reproduced with a failing control and corrected before the separately named second observation. The observer forwards original bytes to the owned loopback service; it generates no inference or tool actions and retries no request.The captured native compaction request retained 15 historical function-call/output pairs; the following inference request had no historical call/output items and instead carried user messages plus a textual summary. This observed run then read contexts 15/16 and the final fixture without another write proposal. Compaction started in the next turn after the original write turn completed, so this does not qualify an intra-turn effect boundary. Recorded connection resets accompanied complete HTTP/SSE exchanges and are not proof of request replay.
The earlier 20-versus-18 proposal failure remains unresolved: this passing observation proves neither a fix nor the original root cause. Approval decisions were synthetic, not Val's acceptance. Personal configuration stayed unchanged, external TCP and outside writes were kernel-denied, and observed owned processes stopped. This run's private user layer was empty, so it supplies no new retained-workspace-trust evidence. Production admission, general action-safe compaction, overflow/OOM and human/device acceptance remain open. Full local receipts and independent audits are retained in the closeout evidence directory.
BunsDev commentedon Nov 11, 2026
The dense-input overflow now has a complete native transport reproduction on clean candidate
da13074cb764264df47e22ddc4ca732247d9ced9. The same four 20,368-byte inputs match the original failed run's hashes. Native compaction completed, but the following actual request retained all three earlier dense user inputs alongside summary/context and the fourth input. Ollama rejected that request at 73,800 tokens against its independently observed 65,536-token slot. Independent review verified seven complete HTTP pairs: six HTTP 200 responses with completed SSE, followed by the HTTP 400 JSON rejection. This is failed qualification: the completed compaction event did not yield a usable next turn.This reproduction establishes the retained-input/overflow observation, not the installed compactor's estimation algorithm or reliable compaction. The version-matched upstream source's
ceil(bytes/4)estimate and 20,000-token retention budget remain an explanatory hypothesis without installed-binary/source build equivalence; exact token contributions are unproven. The original 73,649-token failure is retained separately from this 73,800-token reproduction. The dense run has raw transport and native-event evidence, without a native session snapshot. Modex returned failed, no additional tool call or automatic request retry followed the rejection, and subsequent owned-server termination was cleanup rather than OOM evidence. Global configuration stayed unchanged; external TCP and outside writes were kernel-denied. Receipts and independent review are retained in the closeout evidence directory. No admission or acceptance checkbox is changed.BunsDev commentedon Nov 12, 2026
Reconciled AC3 and AC5 against protected main
0f43631dec22db5ca9390e35613a139ae61bff07. Only these two acceptance boxes are now supported; #380 remains open./v1/responsesrequest contained the first prompt and excluded the queued prompt; the first turn completed and the queued turn was interrupted. This used a scripted loopback server, without model inference. Both unqualified multi-agent flags must be false; enabled, missing and malformed values are rejected by the admission controls and fixtures. The relevant source is identical between the native receipt head63c103c2c73949ffccd975b88131c0399afd592aand actual main.The delivered #498/#499 protected checks and independent criterion audit support this reconciliation. These are capacity/admission results, not whole-issue privacy or runtime acceptance. Implementation step S5 remains unchecked until the explicit waiting-status repair is delivered; S7's older-client presentation remains separate. Selected-endpoint redirect escape, exhaustive failure-path privacy, action-safe compaction and genuine OOM recovery remain open. Product activation, physical-device and human acceptance are not inferred.
BunsDev commentedon Nov 12, 2026
Reconciled implementation step S5 against protected main
4f1d80c5b25115a1debcf37a276d749a245e1589, delivered by PR #500. Independent full-clause audit confirms shared normalized-service capacity, disabled unqualified parallel subagents, bounded or disabled auxiliary work, cancellable waiting with zero queued dispatch, and explicit once-only waiting/continuation notices. Capacity and copy cover Modex runs; they do not claim control over work started by other applications. S5 is now checked, advancing this issue to six of 13 boxes.The delivered execution source and canonical regressions include cancellation at capacity handoff and the actual LocalExecution → ThreadRunner → Store emitted-and-durable waiting projection before native dispatch. The signed actual merge exactly matches reviewed/tested tree
b354cf7cacb617a4fed9cd384551b7c323d79136. Protected queue qualification passed 2,478 unit cases with 36 explicit skips, 518 desktop cases with eight skips, and seven site cases, with zero failures or observed E2E retries.The issue remains open. Selected-origin redirect/privacy guarantees, action-safe compaction, genuine OOM and the complete recovery matrix, older-client presentation, and required native/human acceptance remain separate gaps. Product local execution remains unadmitted; skipped cases and scripted/native-protocol diagnostics do not establish full acceptance. The merged review document retains its pre-merge pending wording until its next evidence reconciliation.