Skip to content

fix: the 4 open sweep issues (#101, #102, #103, #104) - #110

Merged
bketelsen merged 4 commits into
mainfrom
irulan/lodge-fix-the-4-open-sweep-issues-101-t140-lk7ai2aick4ve3vj
Nov 22, 2026
Merged

bketelsen merged 4 commits into
mainfrom
irulan/lodge-fix-the-4-open-sweep-issues-101-t140-lk7ai2aick4ve3vj

Conversation

@frostyard-machines

@frostyard-machines frostyard-machines commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Closes #101, #102, #103, #104.

The 4 open sweep issues, each in its own commit.

#101: the client and the shell reserve the 7 app IDs

kit/manifest and app-contract.md reserve 7 IDs: app, device, gateway, lodge, mcp, nats, oauth. validApp in client/src/messages.ts and in shell/src/model.ts refused only 4 of them. Both lists now hold all 7, with a comment that names the source.

Tests: client/test/messages.test.ts and shell/test/model.test.ts check that each of the 7 is refused and that notes is accepted. Without the fix, gateway, nats and oauth come back true, so the toEqual of 7 falses fails.

#102: a reload of a provider's slots or home keeps its queue

Load kept a provider's queue only when the whole ProviderConfig was equal. If a reload changed only slots or home, the provider got a new queue while requests in flight still held slots in the old one. So it could run up to 2 × slots at once, against "At most slots requests run at once" (inference.md, The queue).

  • New func (q *Queue) Resize(slots int): under the lock, it sets slots and bgMax = max(slots-1, 1), then grants any slots it frees.
  • Load keeps the queue when Type and BaseURL are equal, and calls Resize(max(pc.Slots, 1)) on it. A new type or base URL is a different upstream, so it still gets a new queue.
  • The availability state (checked, once, available, reason) is still kept only when the whole configuration is equal, as before.
  • inference.md gets one line that says what a reload does to a queue. overview.md's queue line follows.

Tests, and how each fails with its fix reverted:

  • TestReloadKeepsQueueWhenHomeChanges: slots 1, one request holds the slot, a reload changes only home. The queue must still count 1 running, and a second request waits until the first releases.
    • With Load reverted: server_test.go:635: after the reload: {Running:0 Waiting:0}.
  • TestReloadGrowsSlotsGrantsWaiter: a reload from 1 to 2 slots grants the waiting request, on the same queue.
    • With Load reverted: server_test.go:665: not granted.
  • TestReloadNewBaseURLGivesNewQueue: a new base URL still gives a new queue (unchanged behaviour).
  • TestResizeGrowGrantsWaiters: a grow from 1 to 3 grants both waiters.
    • With Resize empty: queue_test.go:190: not granted.
  • TestResizeShrinkLetsRunningFinish: after a shrink from 3 to 1, the 3 running requests keep their slots. A waiter is not admitted at 2 or 1 running, only at 0. bgMax follows the new slots.
    • With Resize empty: queue_test.go:217: after Resize(2), bgMax = 2, want 1 and queue_test.go:229: after one release: {Running:3 Waiting:0}.

The tests synchronize on the queue's changed hook and on grant channels, with no sleep.

#103: overview.md says when the socket owner is checked

The owner and peer checks run in apps.Registry.DialContext (checkPeer), once per new connection, and the gateway's transport pools idle connections. overview.md said "before each request". It now says what happens:

  • lodge checks the socket file's owner and the peer (SO_PEERCRED: the manifest's user, or root under socket activation) on each new connection;
  • a pooled connection keeps the peer it checked, since a Unix socket's peer does not change;
  • a change of the manifest's user takes effect for new connections.

This is docs only, with no code change.

#104: the session passes the query to the app's /api

app-contract.md, Public URLs says lodge passes a request's query to the app unchanged. The session dialled a fixed /api and dropped r.URL.RawQuery. It now dials /api? + RawQuery when the query is not empty, and plain /api otherwise. lodge-http.md's Sessions section says so too.

Test: TestSessionPassesTheQuery. /app/notes/api?x=1&y=2 reaches the fake app as /api?x=1&y=2, and /app/notes/api as /api.

  • With the fix reverted: session_test.go:73: /app/notes/api?x=1&y=2: the app saw /api?, want /api?x=1&y=2.

Risk

The PR touches 2 paths of .github/risk-paths.json, both L1:

  • internal/inference/server.go (provider keys and the inference socket). Only Load's choice of queue changes. No key, credential, provider URL or request path is touched. The queue is kept only for the same type and base URL, so no request moves to another upstream. The change tightens the slot limit; it does not widen it.
  • internal/gateway/ws.go (the proxy to app sockets). Only the path of the app's side of the session dial changes, by appending the browser's raw query. The dial target stays ws://<id> on the app's own socket, and the browser checks, the Lodge-* headers and the relay are unchanged. lodge still reads nothing from the query, as the contract says. RawQuery is the parsed URL's query, so it holds no # or path, and websocket.Dial builds the request from it as it would from any query.

Checks

  • make check, make race and make cross pass locally.
  • make client-check and make shell-check run in CI here: the nsl machine was not reachable from this session.

…or home

A reload that kept a provider's type and base URL but changed its slots or home gave it a new queue, so requests in flight held slots in the old one and the provider could run up to twice its slots (docs/specs/inference.md, The queue). The queue now stays and Queue.Resize sets its new slots; availability is still kept only for an unchanged configuration.

Closes #102.
docs/specs/app-contract.md says lodge passes a request's query to the app unchanged; the session dial dropped it.

Closes #104.
…tion

The check runs in the dialer, once per connection, and the gateway pools idle connections.

Closes #103.
@github-actions github-actions Bot added level:L1 Read every line risk:high Touches a path in .github/risk-paths.json labels Nov 22, 2026
@frostyard-machines frostyard-machines added the ready-for-human Reviewed, CI green: ready for Brian to review and merge label Nov 22, 2026
@bketelsen
bketelsen merged commit 909e758 into main Nov 22, 2026
11 checks passed
@bketelsen
bketelsen deleted the irulan/lodge-fix-the-4-open-sweep-issues-101-t140-lk7ai2aick4ve3vj branch November 22, 2026 01:03
frostyard-machines added a commit that referenced this pull request Nov 30, 2026
validApp now refuses gateway, nats and oauth (909e758, #110). An app
with one of those ids that ran on lodge v0.3.0 or older fails in
connectLodge with this client, so the release is a minor, not a patch.
bketelsen pushed a commit that referenced this pull request Nov 30, 2026
* chore(client): changelog and version for 0.3.3

client/v0.3.3 carries one change to the library since client/v0.3.2:
validApp refuses the 3 ids that kit/manifest reserves and the client did
not (909e758, #110). The other commits under client/ since the tag are
dev-dependency bumps (Biome, Vitest) and a README change; none changes
the shipped code in client/src.

package.json takes the new version, as each earlier client release did.

* chore(client): make the release 0.4.0, a minor

validApp now refuses gateway, nats and oauth (909e758, #110). An app
with one of those ids that ran on lodge v0.3.0 or older fails in
connectLodge with this client, so the release is a minor, not a patch.

* docs(agents): a stricter library check is a minor before 1.0

The client release in this PR was first prepared as a patch. Its change
makes validApp refuse ids that lodge v0.3.0 and older accepted, so an
app that worked before can fail: that is a minor before 1.0. The rule
under "A library's release is its tag" says to compare a change with
older lodge tags before picking the version, and a correction record
keeps the case.

* docs(agents): scope the minor-version rule to the client

The UI package's rule 7 asks for a major when a token is removed or
renamed, so the rule names the client and leaves the UI package to its
own rules.

---------

Co-authored-by: frostyard-machines <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

level:L1 Read every line ready-for-human Reviewed, CI green: ready for Brian to review and merge risk:high Touches a path in .github/risk-paths.json

Projects

None yet

2 participants