Repository navigation
fix(oauth): hold a grant item for 1 major version of its app - #94
Merged
Merged
Conversation
A grant stored its items with no version of the app, so the app's next major version, which hearth's manifest diff allows to change what a capability, a selector or a topic means, kept every grant that an admin approved for the old meaning (hearth ADR-0004, Compatibility). - lodge reads the hearth manifest's version, MAJOR.MINOR.PATCH, and disables an app whose version is missing or malformed. The app's line is MAJOR, or 0.MINOR for a version 0.y.z. - An access request records the app's line; an approval stores it with each item. Grant gives the gateway and the broker only the items of the app's current line, so a new line takes the old items out of force until an admin approves them again. An item stored with no line is in force for none. - A request made on an old line can only be declined (409); the consent page says so, and shows the app's version. The grants page marks an item that is not in force. - A reload refilters every event subscription at once, as a grant change does, instead of waiting for the next sweep. - Migration 0006 adds consent_requests.major. ADR-0023 (Proposed) and docs/specs/oauth.md record the rule; the guide says what an owner sees.
…step fails The registry is in force once it loads, so a failed SyncApps must not skip the gateway's tools and the event consumers' refilter: a grant that an app's new major version takes out of force would keep its events until the next sweep. The reload now runs each step, then each reader, and joins the steps' errors. Found by the cross-review.
bketelsen
approved these changes
Nov 17, 2026
This was referenced Nov 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A grant stored its items with no version of the app. hearth's manifest diff lets an app's next major version change what a capability, a selector or a topic means (hearth ADR-0004, Compatibility). So a grant that an admin approved for the old meaning stayed in force on the new major version. This PR binds each grant item to 1 major version of its app.
version(MAJOR.MINOR.PATCH). An app with a missing or malformed version is disabled, with the reason. The line isMAJOR, or0.MINORfor a0.y.zversion (svu'sv0rule, ashearth manifest diffuses it)."major": "0.1"). An approval of an item that the grant holds already sets its line again.Grantgives only the items of the app's current line, to the MCP gateway, to the Connect headerLodge-Grantand to the broker's filters. A new line takes the old items out of force until an admin approves them again on the consent page. An item stored with no line (before this PR) is in force for none.events.Service.AppsChanged), as a grant change does. Before, a manifest change waited up to 1 minute for the sweep. The gateway already re-listed tools on a reload. Once the registry loads, the reload runs every step (the broker'sSyncApps) and then always tells both readers, so a failed step cannot leave the old filters (afterAppsLoad); it reports the steps' errors joined.consent_requests.major(default'', which no approval takes).The rest of lodge's contract is unchanged:
/mcp/<id>withlgm_tokens,agent.sockand the companion slot (frostnotes, frostmail, Porter and the PocketJournal) do not read these grants.Upgrade note. A grant approved before this PR has no line, so it stops at the upgrade. Each principal's agent calls
request_accessonce more, and an admin approves it.Restart. At start, nothing is cached: the gateway reads
Grantat each list and call. Event consumers are rebuilt fromGrantby the sweep (and, after the next change, before/natsadmits clients). Both see the current line only.Risk tier
Risk tier: 3 —
risk:high. Matched paths (.github/risk-paths.json, all L1):internal/oauth/**(auth):Grantreturns a subset of what it returned before (the items of the app's current line).addGrantstores the request's line; it never widens an item. The approval adds 1 refusal (409) before its transaction; the request hash, the CSRF checks and the admin check are unchanged. The item hash on the grants page is unchanged (it ignores the line).internal/events/**(auth): newAppsChangedrefilters each subscription from its principal's grant, with the same fail-closed path asGrantChanged(a failed refilter revokes the client).internal/apps/apps.go(auth): the hearth manifest loader now requires a validversion; a missing one disables only that app.cmd/lodge/main.go(auth): the reload callsAppsChangedon the gateway and the events service after every successful registry load, also when the broker step fails; the step's error is still returned.internal/store/migrations/**(destructive operations):0006only adds a column with a default; no row changes.Docs housekeeping
Verification
make checkgreen (host)make raceandmake crossgreen (host)make client-check,ui-check,shell-check: not run locally; the nsl machine does not answer on this host (nsl run -m lodge trueexits 1 with no output). This PR changes nothing underclient/,ui/orshell/; CI runs those jobs.make mcp-e2e(nsl): not run, for the same reason. The gateway's MCP protocol is unchanged; the Go tests drive it with the Go MCP SDK client..memory/corrections/2026-11-16-pr-94-grant-holds-for-one-major.jsonSyncAppsskipped the refilter): guardcmd/lodgeTestAfterAppsLoadTellsTheReaders, and.memory/corrections/2026-11-16-pr-94-reload-tells-readers-after-a-failed-step.jsonNew tests:
internal/gatewayTestMCPGatewayNewMajorNeedsConsent: hearth's example app at 0.1.0, a grant, a call; the app goes to 0.2.0; the open session getstools/list_changed, loses the tool, the call isinsufficient_scopeand the app sees nothing; the grants page marks the item; an old request's page shows the reason and its approval is 409;request_access, approval, the tool and the call come back.cmd/lodgeTestAfterAppsLoadTellsTheReaders: a failed broker step still runs the later steps and both readers, and its error is returned.internal/oauthTestGrantMajor,TestGrantWithoutMajor;internal/appsTestHearthMajorand 3 new cases ofTestHearthManifestDisabled;internal/eventsTestAppsChangedRefilters.Revert test
In a scratch worktree at
992335f, withinForce's line check replaced byif true(internal/oauth/grants.go) andevents.Service.AppsChangedmade a no-op, with the tests kept:go test ./internal/gateway/ -run NewMajorfails (the session got no notifications/tools/list_changed),go test ./internal/oauth/ -run 'GrantMajor|WithoutMajor'fails (a grant without a line = [...]; want nothing in force), andgo test ./internal/events/ -run AppsChangedfails (the consumer's filters after the reload are [...]). At0e9317a, withafterAppsLoad's loop changed back to an earlyreturn err:go test ./cmd/lodge/ -run AfterAppsLoadfails (ran [sync], want every step, then every reader).Cross-review
openai/gpt-6.1-sol; coderanthropic/claude-opus-5-5. Base789ed5de753a6335c7005efee5b7565e6b71276a.992335ffbdb5921d13168816d3f0dc4c9e058a42, all 20 files: Not ready, 1 blocking finding (high): a failed brokerSyncAppsin the reload returned before the event subscriptions were refiltered, after the new manifest was in force. Fixed in0e9317a.0e9317ade9895a4d676ba73f6879a6a63903974a(diff since992335f): no new findings; the blocker is resolved. Ready, Blocking: none.make mcp-e2edid not run locally (see Verification).