github-permission-singleflight: GitHub permission singleflight #4

Open
std-bot wants to merge 1 commit from task/github-permission-singleflight into main
First-time contributor

Assigned idea

Benchmark authoring specification.

Summary: Add deterministic singleflight behavior to the sidepanel GitHub API permission helper so concurrent callers share one Chrome permission request and all receive the same boolean result.

Task intent: Improve the existing upstream sidepanel permission helper in entrypoints/sidepanel/github-permission.ts so repeated simultaneous calls to requestGitHubApiPermission() do not trigger multiple chrome.permissions.request prompts for the same GitHub API origin.

Benchmark plan: Construct the task package from commit a4939d22bb1e69a7cea56d735b66259b37eb8cc5. The solver-facing work should ask for a small upstream change to entrypoints/sidepanel/github-permission.ts: keep the current origin https://api.github.com/*, keep the fast path when permissions are already granted, preserve the current permissive behavior when the Chrome permissions API is unavailable, and add module-level in-flight request sharing for concurrent calls. The package should include hidden tests that exercise the exported function under mocked chrome.permissions.contains and chrome.permissions.request implementations.

Environment plan: The task environment should be a normal checkout of zhu1090093659/deepseek-pp at the specified commit with repository dependencies installable as usual. The separate verifier environment should not rely on a real browser extension runtime; it should run mocked Chrome permission objects from Python/Node-driven tests against the TypeScript source.

Verifier plan: Create test_outputs.py to inspect and execute entrypoints/sidepanel/github-permission.ts. The verifier should run concrete checks equivalent to: 1) with chrome.permissions.contains resolving true, three calls return true and request is never called; 2) with contains resolving false and three calls started before the first request resolves, contains may be called per caller but request is called exactly once and all callers resolve to true; 3) when that single request resolves false, all concurrent callers resolve false; 4) after the in-flight request settles, a later call may issue a new request if permission is still not contained; 5) when chrome.permissions or its required methods are absent, the function still resolves true. The verifier should fail if the origin differs from https://api.github.com/* or if the implementation serializes by returning stale results forever.

Oracle plan: The oracle solution should edit entrypoints/sidepanel/github-permission.ts by adding a module-scoped let pendingGitHubApiPermissionRequest: Promise<boolean> | undefined or equivalent. After contains reports false, reuse the pending promise if present; otherwise call chrome.permissions.request({ origins }), store that promise, catch failures as false, and clear the pending reference in finally.

Difficulty plan: Current coding assistants may add a cache that permanently remembers denial or approval instead of only deduplicating in-flight prompts, may accidentally change the GitHub API origin string, may remove the non-browser fallback that returns true, or may only add static structure without correctly sharing concurrent asynchronous calls.

Repo patch scope: Expected upstream edits are limited to entrypoints/sidepanel/github-permission.ts; verifier-only files may live outside the repo patch and should not be part of the proposed upstream change.

Anti-leakage notes: Do not expose solver-facing benchmark, harness, Snorkel, Harbor, std-ts, agent, stage, attempt, retry, generated task, or evaluation context. Present the work only as a normal repository improvement.

Approach: Use the existing exported helper as the sole behavior target and add a narrow singleflight guard around the permission request path while preserving current API shape and fallback semantics.

Verification: Run the hidden python test_outputs.py verifier, which should mock Chrome permissions and assert the concrete concurrent-call behaviors for entrypoints/sidepanel/github-permission.ts.

Risk: The main risk is that the repository may not already have a TypeScript test runner configured, so the verifier should be self-contained and mock browser globals rather than depend on extension tooling.

Path rules: task package is tasks/; mutable upstream checkout is tasks//task/environment/repo; benchmark package files are under tasks//task; verifier/container environment belongs under tasks//task/environment; regular and UI verifier logic belongs in task/tests/test_outputs.py and test.sh only runs that file through pytest.

Agent context

Task slug: github-permission-singleflight
Branch: task/github-permission-singleflight

## Assigned idea Benchmark authoring specification. Summary: Add deterministic singleflight behavior to the sidepanel GitHub API permission helper so concurrent callers share one Chrome permission request and all receive the same boolean result. Task intent: Improve the existing upstream sidepanel permission helper in `entrypoints/sidepanel/github-permission.ts` so repeated simultaneous calls to `requestGitHubApiPermission()` do not trigger multiple `chrome.permissions.request` prompts for the same GitHub API origin. Benchmark plan: Construct the task package from commit `a4939d22bb1e69a7cea56d735b66259b37eb8cc5`. The solver-facing work should ask for a small upstream change to `entrypoints/sidepanel/github-permission.ts`: keep the current origin `https://api.github.com/*`, keep the fast path when permissions are already granted, preserve the current permissive behavior when the Chrome permissions API is unavailable, and add module-level in-flight request sharing for concurrent calls. The package should include hidden tests that exercise the exported function under mocked `chrome.permissions.contains` and `chrome.permissions.request` implementations. Environment plan: The task environment should be a normal checkout of `zhu1090093659/deepseek-pp` at the specified commit with repository dependencies installable as usual. The separate verifier environment should not rely on a real browser extension runtime; it should run mocked Chrome permission objects from Python/Node-driven tests against the TypeScript source. Verifier plan: Create `test_outputs.py` to inspect and execute `entrypoints/sidepanel/github-permission.ts`. The verifier should run concrete checks equivalent to: 1) with `chrome.permissions.contains` resolving true, three calls return true and `request` is never called; 2) with `contains` resolving false and three calls started before the first `request` resolves, `contains` may be called per caller but `request` is called exactly once and all callers resolve to true; 3) when that single request resolves false, all concurrent callers resolve false; 4) after the in-flight request settles, a later call may issue a new request if permission is still not contained; 5) when `chrome.permissions` or its required methods are absent, the function still resolves true. The verifier should fail if the origin differs from `https://api.github.com/*` or if the implementation serializes by returning stale results forever. Oracle plan: The oracle solution should edit `entrypoints/sidepanel/github-permission.ts` by adding a module-scoped `let pendingGitHubApiPermissionRequest: Promise<boolean> | undefined` or equivalent. After `contains` reports false, reuse the pending promise if present; otherwise call `chrome.permissions.request({ origins })`, store that promise, catch failures as false, and clear the pending reference in `finally`. Difficulty plan: Current coding assistants may add a cache that permanently remembers denial or approval instead of only deduplicating in-flight prompts, may accidentally change the GitHub API origin string, may remove the non-browser fallback that returns true, or may only add static structure without correctly sharing concurrent asynchronous calls. Repo patch scope: Expected upstream edits are limited to `entrypoints/sidepanel/github-permission.ts`; verifier-only files may live outside the repo patch and should not be part of the proposed upstream change. Anti-leakage notes: Do not expose solver-facing benchmark, harness, Snorkel, Harbor, std-ts, agent, stage, attempt, retry, generated task, or evaluation context. Present the work only as a normal repository improvement. Approach: Use the existing exported helper as the sole behavior target and add a narrow singleflight guard around the permission request path while preserving current API shape and fallback semantics. Verification: Run the hidden `python test_outputs.py` verifier, which should mock Chrome permissions and assert the concrete concurrent-call behaviors for `entrypoints/sidepanel/github-permission.ts`. Risk: The main risk is that the repository may not already have a TypeScript test runner configured, so the verifier should be self-contained and mock browser globals rather than depend on extension tooling. Path rules: task package is tasks/<slug>; mutable upstream checkout is tasks/<slug>/task/environment/repo; benchmark package files are under tasks/<slug>/task; verifier/container environment belongs under tasks/<slug>/task/environment; regular and UI verifier logic belongs in task/tests/test_outputs.py and test.sh only runs that file through pytest. ## Agent context Task slug: github-permission-singleflight Branch: task/github-permission-singleflight <!-- std-ts:idea-pr-body -->
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin task/github-permission-singleflight:task/github-permission-singleflight
git switch task/github-permission-singleflight

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff task/github-permission-singleflight
git switch task/github-permission-singleflight
git rebase main
git switch main
git merge --ff-only task/github-permission-singleflight
git switch task/github-permission-singleflight
git rebase main
git switch main
git merge --no-ff task/github-permission-singleflight
git switch main
git merge --squash task/github-permission-singleflight
git switch main
git merge --ff-only task/github-permission-singleflight
git switch main
git merge task/github-permission-singleflight
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
snorkel/root-repository-maintenance-99f07e1c783943!4
No description provided.