GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(plugin-browser): revoke stale browser grants on startup by feiiiiii5 · Pull Request #61639 · anomalyco/opencode Conversation
|
| return ctx.session.update({ sessionID: session.id, permissions }).pipe(Effect.ignore) | ||
| } | ||
| const page = (cursor?: Session.ListCursor): Effect.Effect<void> => | ||
| ctx.session.list(cursor === undefined ? undefined : { cursor }).pipe( |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
ctx.session.list() without a filter returns every session in the database, not just this location's. Each location starts its own plugin instance, so starting location B clears the grant of a session that is attached right now in location A. I reproduced this: A's permissions went from the two allows to [] while A's attachment was still live. Please filter by ctx.location (directory / workspaceID). Because this runs before the agent transform and tool registration, a large session table also delays every location's startup. Running it in the background (forkScoped) would avoid that.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| ) | ||
| return index === -1 ? rules : rules.toSpliced(index, 1) | ||
| }, current) | ||
| const permissions = withoutAccess(current) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This changes the release behaviour. Before, each release removed one copy of each allow (findIndex + toSpliced), so a replaced attachment kept the new attachment's grant (see the comment above grant). withoutAccess removes every matching allow. If the old attachment's release runs after the new one's grant, the new live attachment loses its tools. It also removes allows a user added to the session on purpose. I'd keep the single-copy removal here and use withoutAccess only for the startup cleanup.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Scope stale-grant cleanup to the current directory and workspace. Remove only one appended grant pair when an attachment is released, preserving ordered user rules. Wait for active and replaced attachment finalizers before plugin teardown completes so a reload cannot revoke its replacement's grants.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Both earlier points are addressed. The startup cleanup now covers only this location's directory and workspace. Re-running my two-location scenario, a live attachment in location A keeps its grant when location B starts, and its state RPC still succeeds. Releasing an attachment removes a single copy of each allow again, and I checked the replace case.
With the issue's kill -9 reproduction, the stale allows are still cleared once the browser plugin loads for the location.
Tests: the core browser-grants test passes (4 tests), and the plugin-browser connection-grants, rpc and tools tests pass (46). typecheck:tsc passes.
Public API: unchanged.
One new point, on the added core test (inline).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const closing = yield* Scope.close(scope, Exit.void).pipe(Effect.forkScoped({ startImmediately: true })) | ||
| yield* Deferred.await(releasing) | ||
| // Let teardown reach its completion wait while the old finalizer remains blocked. | ||
| yield* Effect.yieldNow |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This file is about 200 lines for what it checks, and it's hard to follow. Two tests hold up the old release by matching on the first fiber that calls session.get (old.fiber). Here, the "teardown is still pending" check depends on a single Effect.yieldNow being enough for the scope close to reach its wait. That's a scheduler-order assumption, and if it's wrong, pollUnsafe() can give false results either way. Could you cut this down to the core cases: the cross-location test (lines 18–50) plus one simple replace test? If you keep the teardown-wait test, it would be better to wait on an explicit signal than on yieldNow.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This push changes only the core test, so the fix itself is as I verified at the previous commit.
The replace test is now short and clear, and the fiber-ID matching is gone.
The test thread stays open. The teardown-wait test is still most of the file. It wraps rpc.register and agent.transform to insert finalizers, so it depends on the order finalizers are registered in make. It also swaps yieldNow for closing.currentDispatcher.flush(), which still depends on how Effect schedules fibers rather than on an explicit signal. I'd drop it, or reduce it to one case that waits only on deferreds.
Tests: the core test passed in 8 of 8 runs, and the plugin-browser tests pass (46). typecheck:tsc passes.
Public API: unchanged.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The test thread is addressed: the core test is now the cross-location case plus a simple replace case. The teardown tests that relied on finalizer ordering and the scheduler are gone. The source is unchanged since my last check of the fix against a running server.
Tests: the core test passed in 5 of 5 runs, and the plugin-browser tests pass (46). typecheck:tsc passes.
Public API: unchanged.
No further concerns.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
After the rebase onto dev's state-machine connection, the startup cleanup still works. I re-ran it against the CLI from source, with latest dev as the base.
dev the stale allows survive. With this PR they are cleared once the browser plugin loads for the location.The earlier points (cleanup limited to this location, release behaviour, and the focused tests) still hold after the rebase. Teardown now waits for revokes to drain through dev's state machine.
Tests: the core browser-grants test passed in 5 of 5 runs, and the plugin-browser tests pass (46). typecheck:tsc passes.
Public API: unchanged.
No further concerns.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
browser tools stay listed after a hard restart leaves a stale session grant
There was an error while loading. Please reload this page.