Skip to content

LM-2: hardening on #398: history, credential and deadline fixes (#378) - #402

Closed
BunsDev wants to merge 4 commits into
lm2-fixesfrom
lm2-integrate
Closed

BunsDev wants to merge 4 commits into
lm2-fixesfrom
lm2-integrate

Conversation

@BunsDev

@BunsDev BunsDev commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

LM-2 for #378 under #376: hardening on top of #398. Gate A was accepted on #377 on 2026-10-24. Do not merge yet: this lands after #398, and only with Val's go-ahead. Native metadata evidence is still open.

Stacked on lm2-fixes (#398) at 954cd5b, which this PR does not change. lm2-fixes and lm2-discovery belong to other sessions, so this is a separate branch from a separate worktree (lm2-integrate). When #398 lands, GitHub retargets this PR to main; it will then need a rebase onto the squash.

Fixes (each began with a regression that failed on 954cd5b)

  • History (AC6): a local-connections.json that couldn't be parsed, had the wrong shape or declared a newer version read as empty, and the next save replaced it, losing every profile and tombstone. Only a missing file reads as empty now. list and every edit refuse with a fixed message and leave the file byte-for-byte, and nothing resolves through it. Entries this build can't validate are written back exactly as found and are never listed or resolved.
  • Credential (AC3): a token pasted into the label or a manual model ID was written to the plain-text profiles file and returned in views. Saving it is refused, including a new token already inside a saved name or ID.
  • Credential (AC3/AC6): token entries left by a crash mid-save or by a failed clear on delete stayed in secrets.json. Every successful save now removes local_connection: entries no profile names. Other secrets are never touched.
  • Credential (AC3/AC1): when the saved token couldn't be decrypted, discovery sent its reads without it and could report ready. It now returns unavailable / credential-unavailable, keeps manual IDs and makes zero requests.
  • Bounded time (AC1): each read had a deadline but a whole discovery didn't. 32 slow Ollama /api/show reads held the answer for 7.2 s at a 1 s deadline (about 40 s at the default). Discovery now ends within three per-request deadlines, and unread per-model detail stays unknown.

Regression-only, no defect found: stale answers through LocalModelsService after label-only, manual-only, address and token edits and after deletion; more IPv4/IPv6/IDN endpoint spellings.

Not in this PR

Checks

On b12483c (code; a5da829 adds docs only), base 954cd5b, main at 70123b9. macOS 27.0.1 arm64, Node v24.22.0, pnpm 10.34.5, Electron 44.4.5, Playwright 1.63.0.

  • Focused local-model-* tests: 32/32 passed. Each of the three code commits also passed on its own (29, 31 and 32 tests).
  • pnpm build && pnpm test: exit 0. Worktree 117/117, core 16/16, desktop 1884 tests (1868 passed, 16 skipped, 0 failed), native 21/21, site 10/10, Store 16/16.
  • pnpm typecheck: exit 0.
  • e2e/local-models-ipc.spec.ts: 1/1 passed. There is no renderer change, so the full e2e suite was not run.

PR CI on a5da829 passed every job: unit + e2e (macOS) (required), iPhone companion, CLI and installers on win32 and Linux, and the TypeScript coverage upload.

Every commit is SSH-signed. Details: docs/reviews/2026-10-22-lm2-connections-discovery.md#hardening-2026-10-24.

🤖 Generated with Claude Code

BunsDev and others added 4 commits October 24, 2026 01:08
… of plain text (#378)

Failing-first regressions, each confirmed against 954cd5b before the fix:

- An unreadable, wrongly shaped or newer-version local-connections.json
  read as empty and the next save replaced it, losing every profile and
  tombstone (AC6 history). Only a missing file reads as empty now; list
  and every edit throw a fixed message and leave the file byte-for-byte,
  and resolve/provenance return null. Entries this build can't validate
  are written back exactly as found and are never listed or resolved.
- A saved token pasted into the label or a manual model ID was written to
  the plain-text profiles file and returned in views (AC3). Create and
  update refuse it, including when a new token is already inside a saved
  name or ID. An address change still drops the token, so nothing saved
  can repeat it.
- Token entries left by a crash between saving a token and its profile,
  or by a failed clear on delete, stayed in secrets.json. After every
  successful save, local_connection entries no profile (live or foreign)
  names are removed; other secrets are never touched. SecretStore gains
  names(), which lists entry names only.
- resolve() reports credentialUnavailable when a saved token can't be
  decrypted, for discovery to act on in the next commit.

The token-reflection fixture no longer saves a manual ID holding the
token, since that is now refused at save time.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…adline per discovery (#378)

Failing-first regressions, each confirmed against 954cd5b before the fix:

- When a profile's saved token couldn't be decrypted (keychain locked or
  unavailable), discovery sent the metadata reads without it and could
  report "ready" from an unauthenticated answer. It now returns
  "unavailable" with the new fixed reason credential-unavailable, keeps
  manual IDs, and makes zero requests (AC3, AC1).
- Each read had a deadline but a whole discovery did not: 32 Ollama
  /api/show reads just under the per-request deadline, four at a time,
  held the answer for ~7.2 s at a 1 s deadline (~40 s at the default).
  A discovery now ends within three per-request deadlines: listings use
  at most two, and per-model reads share what remains. Detail still
  unread at the deadline stays "unknown", not a failure; a real cancel or
  supersede still returns stale.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ngs (#378)

Regression coverage only; both passed on first run against 954cd5b, so
neither found a defect.

- Through LocalModelsService (the path local-models:command takes), a
  slow read is stale after a label-only, manual-IDs-only, address or
  token edit, and after deletion; an untouched profile still reads. The
  existing stale test drove the store and invalidate() directly.
- Endpoint policy: octal and trailing-dot IPv4 and fullwidth "localhost"
  normalize to loopback origins; IPv4-compatible, NAT64 and other
  embeddings of 127.0.0.1, "localhost." and port 65536 are refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Receipt section "Hardening, 2026-10-24": each defect, the failing
assertion it began with on 954cd5b, the regression-only coverage that
found nothing, request counts, and exact command results on b12483c.
Status names the hardening on lm2-integrate.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vercel

vercel Bot commented Oct 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
modex Ready Ready Preview Oct 24, 2026 6:17am UTC

Request Review

@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: TypeScript

TypeScript / code-coverage-agent

lm2-fixes 70123b9 lm2-integrate a5da829 +/-
65% 65% 0%
View coverage of the 10 most impacted files.
File lm2-fixes 70123b9 lm2-integrate a5da829 +/-
apps/desktop/sr...kends/claude.ts 98% 98% 0%
apps/desktop/sr...ckends/codex.ts 98% 98% 0%
apps/store-desk...rc/main/demo.ts 95% 95% 0%
apps/desktop/sr...gine/secrets.ts 100% 100% 0%
apps/desktop/sr...ngine/titles.ts 96% 96% 0%
apps/desktop/sr...dels/service.ts 0% 95% +95%
apps/desktop/sr.../connections.ts 0% 100% +100%
apps/desktop/sr...ls/discovery.ts 0% 100% +100%
apps/desktop/sr...point-policy.ts 0% 100% +100%
apps/desktop/sr...-connections.ts 0% 100% +100%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

@BunsDev

BunsDev commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

Superseded: this work landed on main through #403 as e17aebd2fd4a2c691ee4e8946b5c2ef767aa023a, a single squash of #398's commits, #402's hardening and the LM-1 adoption. Closing so it isn't merged separately. The branch and its worktree are left as they are, and the PR can be reopened if needed.

This branch was successfully deployed

1 active deployment
Preview — a5da8292 Deployed Oct 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant