principal pending snapshot: index hook-routed requests by session so a grant's read cost ignores other sessions

Open
#9,128 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript, node.js

Research direction

Start in packages/server/src/principal-pending-permissions.js, especially collectPendingPermissions and the hook-routed read. Trace where pending requests are inserted and removed on answer, timeout, abort, drain, and session teardown, then find the related tests. Done means authorized snapshots touch only their sessions' entries and tests show the index stays aligned with the store across each removal path.

Written by the indexing model from the issue text.

Description

enhancement from-review server

Context

Identified during review of PR #9127 (S4 of #9112, closes #9119).

Location: packages/server/src/principal-pending-permissions.js (collectPendingPermissions, the hook-routed read)

Description

A principal's principal_pending_permissions snapshot reads the hook-routed store by iterating every entry of pendingPermissions and looking up its owner in permissionSessionMap.

  • With an empty authorized set the scan is skipped (#9127).
  • With a non-empty grant it is still O(total hook entries across all sessions).

So the work behind a granted session's snapshot depends on how many hook prompts are pending in sessions the principal cannot see. No other session's content is read or returned; only the cost depends on it.

Repro:

  1. Grant session s1.
  2. Put 1,000 hook entries owned by an ungranted session s2 in the store.
  3. Request a snapshot for s1.

The reply is empty, but all 1,000 owners are consulted.

Acceptance Criteria

  • The hook-routed pipeline keeps a session-to-pending-request index, maintained on insertion and on every removal path (answer, timeout, abort, drain, session teardown).
  • The snapshot iterates only the authorized sessions' entries.
  • A test with a non-empty grant and an access trap on unrelated store entries proves no unrelated entry is touched.
  • A test proves the index cannot drift from the store, including after the removal paths.
Dominant language
JavaScript
Stars
7
Forks
1
Avg merge
2h 3m
Merged PRs (30d)
333

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from blamechris/chroxy

All issues in blamechris/chroxy

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.