Repository navigation
Description
Outcome and dependencies
Persist user-approved local connections and enumerate their models without scanning the machine, exposing credentials or sending project content.
Parent: #376. Blocked for completion by: #377 (LM-1: accepted identity/capability/migration contract and native configuration map). Delivery group: Local models v1 / Gate B. Priority: P1. The shared execution contract and privacy invariants in #376 apply. Dependencies refer to accepted artifacts, not unrelated producer issue closure.
Context and source entry points
Refresh current main, scoped instructions and open PRs. Publication baseline: ec7be578765f9ce54976882853e57ca190252361. Existing: apps/desktop/src/main/engine/{store,secrets}.ts and the actual main/preload IPC registration identified in #377. Proposed: apps/desktop/src/main/engine/local-models/{connections,discovery,endpoint-policy}.ts, apps/desktop/test/local-model-discovery.test.ts. Reuse equivalent existing mechanisms rather than duplicating them.
Consumes: #377's connection/model/qualification schema. Produces: main-owned persisted profiles, narrow validated discovery commands, bounded non-secret model descriptors and revision-aware discovery results for execution and UI consumers.
Implementation steps
- Add explicit Ollama, LM Studio and Custom Responses connection settings backed by main-owned storage. Initial scope is same-machine loopback only; defer LAN/remote configuration. Metadata adapters may differ, but share the execution/identity contract.
- Validate IPC sender, request schema, connection ownership/revision and endpoint in main. Allow explicitly configured loopback HTTP(S) destinations only. Normalize IPv4/IPv6; reject credentials-in-URL, non-HTTP schemes, non-loopback resolution, unexpected paths and redirects outside the approved origin. Protect against hostname-resolution changes. Never execute renderer-supplied auth helpers or shell strings.
- Store optional local-server credentials with the existing encrypted secret store. Renderer receives only an opaque reference/status. Never reuse or forward cloud account credentials to a local endpoint. Redact secrets before logs/persistence/export, not only in the UI.
- Fetch bounded runtime metadata with deadlines, cancellation, bounded response size and stale-result protection. Distinguish installed, loaded and unavailable when exposed; otherwise say unknown. Keep exact model IDs opaque, including aliases/slashes/spaces where the runtime accepts them. Support explicitly entered IDs when discovery is incomplete.
- Represent generative, embedding, decision and other model types accurately where known. Metadata-advertised tools are not qualified tool use. Exclude known cloud-routed models from local-only selection; unknown downstream inference location remains unverified.
- Opening Settings or refreshing must not install a runtime, download weights, load/unload models, scan directories or probe arbitrary ports. Explain separately that an explicit user-started inference turn may cause the selected runtime's ordinary cold load.
- Define profile edit/delete behavior: revision changes invalidate stale discovery/qualification; active runs retain their snapshot; subsequent execution cannot resolve deleted credentials or silently rebind to a replacement profile. Preserve readable historical provenance.
Acceptance criteria
- AC1: normal, empty, malformed, unavailable, authenticated and delayed metadata fixtures work through main/IPC without inference or project-data transmission.
- AC2: non-loopback, URL injection, IPv4/IPv6 normalization, DNS/redirect and forged-IPC cases cannot bypass the endpoint policy.
- AC3: tokens are absent from renderer state, URLs, diagnostics, snapshots and exported records; cloud account credentials are never forwarded.
- AC4: identical model IDs on different connections remain distinct targets; a delayed response after connection edit/switch cannot appear current.
- AC5: custom/manual IDs remain available for explicit compatibility tests; known embedding-only models cannot be selected as coding agents.
- AC6: discovery causes zero installs/downloads/model loads/port scans; profile deletion/edit preserves history and cannot redirect an existing run.
Verification and handoff
Write failing-first endpoint, credential, discovery and race tests. Run pnpm build && pnpm test; UI changes also pnpm test:e2e, plus focused tests from current scripts. Record actual request counts, redaction checks, SHA and result evidence. Metadata requests to a real user-installed runtime need appropriate authorization and no private prompt data. Update status and a dated review receipt. No merge/release/global configuration writes.
Long-running goal prompt
Implement LM-2 in TypeSafeAI/modex under #376 after consuming #377's accepted contract. Read current AGENTS.md, source, open PRs and the tracker execution contract; verify main and worktree ownership. Start with failing endpoint, credential and stale-response tests. Build only main-owned profiles and bounded metadata discovery for explicit loopback connections, using existing encrypted secret storage. Return non-secret descriptors with accurate unknown/installed/loaded/capability states and exact model IDs. No inference, downloads, filesystem scans, arbitrary port discovery or global CLI configuration changes. Implement one acceptance slice at a time, run targeted/full checks, update status/evidence and prepare signed commits. Checkpoint SHAs, versions, exact results, unresolved gates and one next action. Do not merge or release.
Follow-up / resume prompt
Resume LM-2 from its live issue/PR and checkpoint. Verify ownership, actual diff and #377's current contract. Retest forged IPC, URL canonicalization, IPv4/IPv6, DNS/redirect boundaries, same-name models and late responses after profile edits/deletion. Inspect logs/snapshots/exports for tokens and count requests to prove discovery never starts inference or downloads. Continue the smallest failing criterion without adding remote connection management or installers. Rerun smoke/full checks, record fresh criterion-level evidence and leave unavailable native/human gates open. No merge, publication or scope expansion.
Activity
test: stop the LM-2 endpoint fixture echoing request paths (CodeQL js…
BunsDev commentedon Oct 23, 2026
Refreshed goal prompts — 2026-10-23 (
mainat203a350)On
mainalready:apps/desktop/src/main/engine/local-models/onmain, anddocs/status.mdhas no local-model entry.Still open:
lm2-discovery, head3654053, six commits onec7be57). It adds a loopback-only endpoint policy, main-owned profiles inapp/local-connections.jsonwith tokens in the existingSecretStore, and bounded discovery for Ollama, LM Studio and Responses-compatible servers. These go through one strictlocal-models:commandIPC channel that the Store desktop demo refuses. There is no UI, no execution binding and no inference. All evidence comes from synthetic loopback fixtures, written up indocs/reviews/2026-10-22-lm2-connections-discovery.md. CI is green, includingunit + e2e (macOS), and GitHub reports the PR mergeable. The PR says not to merge yet.connections.ts; the second is not yet reproduced, so confirm it with a failing test first. They are recorded in an unpublished review in thelm-foundationworktree.connections.tsreplaces or clears the token before it writes the new revision. If the profile write then fails, the old revision resolves the new credential. I confirmed the ordering in the source.048d1e8onlm1-contract). LM-2: secure local connections and bounded model discovery (#378) #386 must adopt its types: model refs gainschema: 1,ConnectionRefgets one owner, and LM-2: secure local connections and bounded model discovery (#378) #386'sollama/lmstudio/responsesmetadata runtimes map onto LM-1's profile kinds.Long-running goal prompt
Follow-up / resume prompt
BunsDev commentedon Oct 24, 2026
LM-2 checkpoint, 2026-10-24 (
mainat70123b9)Owner: this session, in its own worktrees
lm2-integrateandlm2-adopt.lm2-fixes(#398),lm2-discovery(#386) andlm1-contract(#397) belong to other sessions and were not edited.Draft #402 (
lm2-integrate): hardening stacked on #398 at954cd5b. Heada5da8292b87b89b142854c8c0dba31e692ef2d63; code atb12483c2439639ae274d1fcb2bca03e638a03207. Every fix began with a regression that failed on954cd5b:secrets.json(AC3/AC6). They are now swept after every successful save, and other secrets are never touched;ready. It is nowcredential-unavailable, with zero requests;/api/showreads took 7.2 s at a 1 s per-request deadline. It now ends within three per-request deadlines, and unread detail staysunknown.Regression-only coverage found no defect: stale answers through
LocalModelsServiceafter every kind of edit and after deletion, and more IPv4/IPv6/IDN endpoint spellings.Results on
b12483c: focused 32/32;pnpm build && pnpm testexit 0 (worktree 117, core 16, desktop 1884 with 1868 passed and 16 skipped, native 21, site 10, Store 16);pnpm typecheckexit 0;e2e/local-models-ipc.spec.ts1/1. PR CI ona5da829passed every job:unit + e2e (macOS)(required), iPhone companion, CLI and installers on win32 and Linux, and the TypeScript coverage upload.Local
lm2-adopt(not pushed): LM-1 adoption stacked on #402. Head2d4536d; code at121170801d504c96ac57a48600f1379c0da1dbdb.91deb281ad36f522636d9b6e2fe55105b74d47ae. That commit is still only on the LM-1 session's local branch (LM-1: local-model contracts and native feasibility (#377) #397 is atc30633d), so this branch can't be pushed until91deb28is published unchanged, or rebased if it changes.ConnectionRefand schema-1LocalModelRefnow come fromshared/local-models.ts.advertisedby [P1][LM-1] Define local-model contracts and prove the native Codex integration seam #377'sCapability(imagesinstead ofvision;structuredOutputs,resumeandcancellationareunknown).NODE_USE_ENV_PROXY/--use-env-proxynever route a read or its token throughHTTP_PROXY. The test fails ifagent: falseis removed.pnpm build && pnpm testexit 0 (desktop 1898 with 1882 passed and 16 skipped; other suites as above); typecheck exit 0; IPC e2e 1/1.Versions: macOS 27.0.1 arm64, Node v24.22.0, pnpm 10.34.5, Electron 44.4.5, Playwright 1.63.0. No real runtime was contacted. Every result is fixture or real-Electron evidence, not native.
Still open:
lm2-adoptmay land before that.91deb28on LM-1: local-model contracts and native feasibility (#377) #397.Next action: once
91deb28is onorigin/lm1-contract, pushlm2-adoptand open it as a draft stacked on #402.BunsDev commentedon Oct 24, 2026
LM-2 checkpoint update (
mainat03ce71a)The previous checkpoint's next action is done. LM-1's reconciliation was published as #400 (
lm1-handoffatcb7ca6c, which descends from91deb28with identical contract files), and #397 merged asffb9e1d.lm2-adopt, head5652180e76b18bb126550ebaeb6617e5e1ed33f3) is stacked on LM-2: hardening on #398: history, credential and deadline fixes (#378) #402. It merges Finish LM-1 identity reconciliation and reproducible probe handoff (#377) #400's head. On top of that it adopts LM-1'sConnectionRefand schema-1LocalModelRef(the LM-1 consumer patch, applied unchanged), keysadvertisedbyCapability, and adds the env-proxy regression.1cf5ca2643d44ce9aec4a3dca5a3a70426c0983f: focused 42/42;pnpm build && pnpm testexit 0 (desktop 1907 with 1891 passed and 16 skipped; worktree 117, core 16, native 21, site 10, Store 16); typecheck exit 0; IPC e2e 1/1. Hosted CI is pending.a5da829, includingunit + e2e (macOS).Landing order, none of which is authorized here: #377 acceptance, then #400, then #398 (or #386), then #402, then #403. Each stacked PR needs a rebase after the squash below it.
Still open:
Next action: Val decides Gate A on #377.
Merge main (bb0e1a4: #400 landed) into LM-2 adoption (#378)
docs: LM-2 adoption results after #400 landed on main (#378)
BunsDev commentedon Oct 24, 2026
LM-2 note (
mainatbb0e1a4): #400 landed. Draft #403 (lm2-adopt) now merges thatmain(headc7107c3350ebdf5dde5edfeace5c161af864eb12, code3457e0ad5a7c7503cd4a968cdce21224e85109a7), so its diff againstmainis only the 17 LM-2 files. The only conflict was the adoption paragraph indocs/local-models.md, and this branch's text was kept.Fresh local results on
3457e0a: focused 42/42;pnpm build && pnpm testexit 0 (desktop 1907 with 1891 passed and 16 skipped; native/package 26 with 21 passed and 5 skipped from #396's native tests; worktree 117, core 16, site 10, Store 16); typecheck exit 0; IPC e2e 1/1. Hosted CI on the previous head5652180was all green.Draft #402 still merges cleanly with
main.Remaining landing order, none of it authorized here: #377 Gate A recorded, then #398 (or #386), then #402, then #403.
Next action: Val records Gate A on #377.
docs: record Gate A acceptance for the contract LM-2 consumes (#377, #…
BunsDev commentedon Oct 24, 2026
LM-2 checkpoint: consuming the accepted contract (
mainatbb0e1a4)Gate A was accepted on #377 on 2026-10-24, narrowly, for
mainatbb0e1a42ac7bb3e11ccfee05a40d8a02f1dc10c4and the recorded Strata combination. LM-2 now consumes that accepted contract.lm2-adopt, head2956c1a) is ready for review. Its LM-1 files are byte-identical tobb0e1a4.ConnectionRef/schema-1LocalModelRefcome fromshared/local-models.ts,advertisedis keyed byCapability, and it adds the env-proxy regression. The docs now record the acceptance. The code is unchanged since3457e0a: local results there were focused 42/42 andpnpm build && pnpm testexit 0 (desktop 1891 passed, 16 skipped). Hosted CI was all green onc7107c3and again on2956c1a(docs only), including the requiredunit + e2e (macOS).lm2-integrate, heada5da829) is ready for review: five fixes, each failing-first; all hosted CI green.Neither is merged. Landing order: #398 (or #386), then #402, then #403. Each needs Val's go-ahead and a rebase after the squash below it.
Still open:
Next action: Val chooses between #386 and #398 and gives the go-ahead to land #398, which unblocks #402 and #403.
Merge main (21e50ba) into LM-2 for landing (#378)
docs: LM-2 lands through #403, superseding #386, #398 and #402 (#378)
Merge main (e5252ea) into LM-2 for landing (#378)
docs: LM-2 open items after the approved metadata boundary and runtim…
BunsDev commentedon Oct 24, 2026
LM-2 landed on
mainase17aebd2fd4a2c691ee4e8946b5c2ef767aa023a(#403)Val asked for #403 to land on
main. It was retargeted fromlm2-integratetomainand went through the merge queue as one squash. That carries #398's six commits and two review fixes, #402's hardening and the adoption of LM-1's accepted contract.002f65b: 17 LM-2 files. GitHub verified the signature on the squash commit, and the queue's requiredunit + e2e (macOS)run passed.c592eee, unchanged through002f65b): focused 42/42;pnpm build && pnpm testexit 0 (desktop 1955 tests, 1938 passed, 17 skipped; native/package 26, 21 passed, 5 skipped; worktree 117, core 16, site 10, Store 16); typecheck exit 0; IPC e2e 1/1.Still open on #378:
Next action: once a local generative model is installed and Val authorizes it, run LM-2 discovery against it and record the result in
docs/reviews/2026-10-22-lm2-connections-discovery.md. LM-3 (#379) can build onmainnow.test: name the client selecting a target in the token records fixture (…
test: name the client selecting a target in the token records fixture (…
Prove global Codex config bytes and token records; redact tokens acro…
test: name the client selecting a target in the token records fixture (…
Prove global Codex config bytes and token records; redact tokens acro…
test: name the client selecting a target in the token records fixture (…
BunsDev commentedon Nov 12, 2026
LM-2 implementation step 6 is now supported on protected main
5f1f1fe8bfa93ee971de7b443f794335ae9c414e, delivered by #498. The Settings explanation distinguishes metadata-only checks from an explicit first-message cold load and keeps execution admission unavailable. Refresh enumerates saved explicit profiles; discovery uses fixed bounded metadata adapters, with no runtime installer, model download/load/unload, filesystem scan or arbitrary-port probe.The protected queue run passed the actual Settings add/list/Refresh/remove case, whose fixture records only metadata GETs. Its complete macOS log records 2,471 unit passes with 36 skips, 514 desktop E2E passes with 8 skips, and 7 site passes. The earlier criterion audit’s 24 source hashes were independently revalidated against the actual merged tree before this reconciliation.
Only the cold-load/metadata explanation step is being ticked. The manual-ID visibility repair and added empty/malformed/delayed IPC regressions are still on the separate
lm2-visibilitycandidate; full E2E is running and they have not been delivered. Packaged secure-storage acceptance and the full remaining issue criteria stay open. Metadata request counts do not establish inference compatibility or the runtime’s internal behavior.BunsDev commentedon Nov 12, 2026
LM-2 complete literal-criteria audit and native credential receipt
All seven implementation steps and six acceptance criteria are supported on signed protected main
5a580d4f98f5b1c62c5801db4400d5b533634082. The 20 credential/discovery/identity/IPC/export source and test files in the independent audit are byte-identical to their reviewed versions; the intervening #505 runner changes retain the local pinning/no-cloud-fallback guards. This is a narrow consumer check, not a review of the entire credit-conservation feature. The accepted #377 contract dependency is satisfied.The protected #503 queue passed 2,478 unit cases with 36 skips, 522 desktop cases with eight skips and seven site cases, with zero failures or observed retries (required macOS job). Relevant cases and unchanged source were rechecked against current main. Production references: shared encrypted store, local connection namespace, token/record/export regressions and canonical credential assertions.
The private QA artifact is ad-hoc macOS arm64 Modex 0.4.2, built from docs head
2825d145ef2ea2297e31553c08a04f57a1be3925with application inputs equal to protected558b54f8. ASAR SHA-256:9f8f2334167e87706eb6a177f745a21e8fb2c10f30943617a5a5114d21e4ec66. The first canonical invocation timed out clicking Settings before key entry; Val observed no Keychain prompt, and the cause remains unestablished. A separate read-only Settings diagnostic passed. One explicitly recorded second canonical invocation then passed the unchanged original assertions: packaged Keychain backend, synthetic key outside state.json, ciphertext without plaintext including after base64 decoding, 0600 file, masked/cleared input, retrieval after reopening and Clear. Result: one pass, zero skips and zero framework retries. The app closed, private canonical fixture directories were cleaned by the test, artifact hashes stayed unchanged and strict deep codesign verification returned zero. No model turn ran and the installed user app was not replaced or closed.External retained receipts: full 13-clause independent audit SHA-256
72a20278a2274d42b748976b7add5066c955501251d8b2aaa7cc4eada49f2976; native terminal independent review02b30a3b37017452a204cc88c7ab550024c12ef0bb12222075b0f2ff6d7476ef; native terminal auditfdd6f9518457e692df9fae11b624826e4d5f5a00f84f9bea7e6285433fe4b628. First-failure logs and both subsequent invocations remain retained. This closes only LM-2's literal metadata/credential requirements. It does not establish cold-start reliability, local coding compatibility, offline privacy, Windows/Linux native-store qualification, human accessibility, product activation or release/notarization. Parent #376 and the downstream issues remain open.