Repository navigation
Add owner-scoped grant listing and opt-in multipart bearer transport - #5
Conversation
Owner-scoped, paginated grant discovery:
- listGrants(browserContext, { ownerPrincipal, cursor, limit, statuses })
returns the signed-in owner's approved grants as the same safe GrantView
that getGrant returns, newest indexed first, with bounded keyed reads
(default 20, maximum 100) and an owner-bound, integrity-checked cursor.
- A separate owner-index collection is written ahead of each approval in
the owner's own partition. Storage Core transactions are single
partition, so no cross-partition atomicity is claimed; listing re-reads
the authoritative grant head and filters by owner, issuer, and resource,
so a leftover entry never surfaces another principal's grant.
- backfillGrantIndex is a bounded, idempotent maintenance scan that indexes
approved grants stored before the index existed.
Opt-in multipart transport for protected resources:
- createProtectedResourceAuthenticator({ ..., multipart: { maxBytes } })
accepts multipart/form-data (default 1 MiB, ceiling 16 MiB); without the
option multipart stays rejected.
- Header checks and the bearer header run before any body byte is read; a
declared oversize body is rejected up front and a streamed one is
cancelled at the bound. The body is parsed from a clone, returned as
result.form, and the original request stays readable.
- Credential field names and issued credential values in form parts are
rejected; query credentials remain rejected.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
OpenRouter review posted ( |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
OpenRouter pull-request review
Verdict: issues
Scope: full-pr (full-pr)
Mode: initial
Commit: 33d6a6ac9f7d75807b9a14f89b1a64a35fb33492
Judge: openai/gpt-5.6-luna
Cost: $0.2291 (lanes $0.2221 + judge $0.0070) + at least $0.0926 (incomplete)
Lanes
openai/gpt-6.1-sol: ok (8 finding(s), 104.9s, 272598+4342 tokens (217905 cached), 6 tool round(s), via Azure, $0.22)z-ai/glm-5.3-flash: ok (11 finding(s), 765.8s, 3373179+62301 tokens (3122688 cached), 37 tool round(s), 1 retried request(s), salvaged finish, via Novita, at least $0.0926 (incomplete))
Findings
🔴 Issue 1 — Oversize rejection leaves the upload source uncancelled
packages/agent-access/src/http.ts:747 · bug · identified by openai/gpt-6.1-sol
When an upload exceeds maxBytes, the authenticator returns 413 without cancelling the original upload source. A host that returns the rejection without consuming the original request can leave the source and its resources alive.
request.clone() tees the body. Erroring the transform cancels only the clone's branch; the unread original branch prevents cancellation from propagating to the source. Cancel both branches on rejection, while preserving the original body on success.
The multipart cancellation test records state.cancelled but never asserts it; its pull-count assertion proves bounded consumption, not cancellation. By contrast, tests/http.test.ts explicitly asserts source cancellation for the existing form transport.
🟠 Issue 2 — Stale authentication after multipart parsing
packages/agent-access/src/http.ts:850 · risk · identified by openai/gpt-6.1-sol
An agent can start a valid upload, delay its remaining bytes until the token expires or the owner revokes the grant, then finish the upload and receive successful access with the old permissions.
The service authentication completes before multipartForm runs, and the saved delegated result is returned after parsing without another check. The byte limit does not bound upload duration. Keep the initial check to prevent unauthenticated body reads, but authenticate again after parsing before returning access.
service.authenticate explicitly fences overlapping revocation and rechecks expiry before returning, and tests/storage.test.ts pins those behaviors. Those guards finish before this newly introduced await. The documented absence of an atomic authorization lease does not eliminate this potentially arbitrarily long gap inside the authenticator.
🔴 Issue 3 — Incorrect parsing of quoted MIME parameters
packages/agent-access/src/http.ts:711 · bug · identified by openai/gpt-6.1-sol
A valid upload with Content-Type: multipart/form-data; boundary=synthetic-upload-boundary; foo="a;b" is rejected with 400 before authentication or parsing.
Splitting the header on every semicolon splits valid quoted parameter values. The resulting b" fragment has no equals sign and triggers invalidRequest. The same approach also does not enforce the distinction between an unquoted MIME token and a quoted boundary value. Use quote-aware MIME parameter parsing while retaining duplicate-boundary detection.
The multipart header tests cover missing, duplicate, and invalid boundaries, but do not cover valid quoted extension parameters. The runtime parser cannot compensate because this check rejects the request first.
🔵 Issue 4 — Null multipart bound silently selects the default
packages/agent-access/src/http.ts:693 · nit · identified by openai/gpt-6.1-sol
A JavaScript host supplying multipart: { maxBytes: null } gets an enabled 1 MiB authenticator instead of the documented construction error for an invalid bound. A malformed configuration therefore silently changes behavior rather than failing validation.
The nullish-coalescing expression treats null like an omitted optional property. Default only when maxBytes is undefined, then validate every supplied value.
The TypeScript interface excludes null, but runtime configuration and JavaScript consumers can supply it. The construction tests check several invalid numbers but omit null.
🔵 Issue 5 — Cursor tamper-rejection guarantee exceeds the implementation
docs/API.md:152 · nit · identified by openai/gpt-6.1-sol
A caller can change a cursor's position, recompute the public SHA-256 check, and have the altered cursor accepted. The documented guarantee that an altered position or check fails is therefore not true for deliberately modified cursors.
grantCursorCheck contains no secret, and the cursor exposes every input required to recompute it. Describe this as a public checksum that detects inconsistent edits, rather than tamper-resistant integrity, or use authenticated integrity if rejecting deliberate edits is actually required.
Owner authorization is still checked on every page, so this does not expose another owner's grants. The tampering tests change the position without recomputing the checksum and consequently do not establish the stronger documentation claim.
🔵 Issue 6 — Multipart memory estimate omits parsed-form overhead
docs/HTTP.md:111 · nit · identified by openai/gpt-6.1-sol
A host budgeting approximately twice maxBytes per upload can substantially underestimate memory for bodies containing many small parts or large text fields, potentially exhausting memory under concurrency.
The unread tee branch retains raw bytes, but the parsed FormData also allocates strings, files, and per-entry objects. Numerous tiny parts can amplify object overhead well beyond the raw byte count; text representation and transient parser buffers add further costs. Qualify the estimate as applying to simple file uploads, not a general memory bound, and consider a part-count limit if bounded parsed-form overhead is intended.
The implementation limits streamed bytes only. Inspection of multipartForm and the multipart tests found no part-count or parsed-allocation bound.
🔵 Issue 7 — Default multipart limit is not behaviorally tested
tests/multipart.test.ts:324 · nit · identified by openai/gpt-6.1-sol
Changing the implementation's default multipart limit above the documented 1 MiB would leave the construction-bound test passing.
The test compares two locally declared constants, rather than exercising an authenticator created with multipart: {}. All default-option uploads elsewhere in the suite are small. Add an upload exceeding 1 MiB through the default authenticator and assert 413, preferably with an exact-bound acceptance case as well.
Explicit small limits and the maximum construction value are tested, but neither establishes the runtime default.
🔵 Issue 8 — Backfill test does not assert pagination termination
tests/listing.test.ts:500 · nit · identified by openai/gpt-6.1-sol
A backfill regression that continues returning a non-null cursor after all grants have been indexed can pass this test, despite causing the documented maintenance loop to run indefinitely.
The test stops after 100 iterations even when no page reports nextCursor: null. Its final assertions require four indexed grants and merely more than four scanned rows, which repeated terminal pages can satisfy. Assert that a null continuation was reached, or throw when the safety bound is exhausted.
The separate everyPage listing helper already throws when listing fails to terminate; the backfill loop has no equivalent guard.
🟠 Issue 9 — Multipart part names are not scanned for issued credentials, unlike values and filenames
packages/agent-access/src/http.ts:775 · risk · identified by z-ai/glm-5.3-flash
A client can smuggle a live Agent Access credential through an opted-in multipart request in a part NAME: Content-Disposition: form-data; name="pgt1.<43-char locator>.<43-char secret>" with any value is accepted, while the same string as a field value or filename is rejected with 400. A host that logs form field names (a common audit pattern) would persist a bearer credential, defeating the feature's stated guarantee that "credentials still come only from the header".
In multipartForm (packages/agent-access/src/http.ts:774-778), each entry is checked with CREDENTIAL_FIELDS.has(name.toLowerCase()) (a fixed field-name set) and ISSUED_CREDENTIAL.test(text) where text is only the string value or the File.name — the part's name attribute itself is never matched against the credential-shape regex. The filename case shows the intent was to scan identity-bearing strings wherever they appear; docs/HTTP.md's sentence ("any text value or filename containing an issued Agent Access credential") documents the hole rather than closing it.
Checked: grep shows ISSUED_CREDENTIAL has this single use in the package; the test at tests/multipart.test.ts:201 covers field names, values, and a filename but no credential-shaped part name. Fix is one extra ISSUED_CREDENTIAL.test(name) in the same loop.
🟠 Issue 10 — Every approval now hard-depends on a second Storage Core collection; upgrade provisioning is undocumented
packages/agent-access/src/service.ts:154 · risk · identified by z-ai/glm-5.3-flash
After this change, every approve call performs reads and a transaction against the new agent-access.owner-index.v1 collection: the constructor wires options.store.collection(ownerIndexRecords) (packages/agent-access/src/service.ts:154) and approve calls indexGrant (service.ts:829) before the grant transition. If the host's storage backend cannot create or write that second collection after an upgrade — e.g., a D1 database provisioned by migration scripts, a restricted DB role, or an adapter that maps collections to separate tables — every approval fails with server_error (503) at runtime. Construction still succeeds, so the breakage appears only on the first approval after deploy, on a flow that worked before the upgrade.
docs/API.md documents the collection's shape and row cleanup but never tells an upgrading host to verify that its store can host the second collection, and the PR description only asserts "No schema change touches agent-access.records.v1".
Proof gap: the Storage Core adapters (@pegma/storage-core 0.4.0, azure-tables, cloudflare-d1) are external to this checkout, so I could not verify whether collections are created lazily. If they are, the residual cost is only the undocumented operational dependency rather than a hard breakage.
🟠 Issue 11 — Backfill and most listing behaviors are only exercised on the memory store despite the claimed three-backend coverage
tests/listing.test.ts:186 · risk · identified by z-ai/glm-5.3-flash
backfillGrantIndex is the package's first service-path use of Storage Core's cross-partition scan, and it never runs against Azurite or Miniflare D1. In tests/listing.test.ts only the first two tests (pagination, list-then-revoke) live inside the storeFactories loop (line 112); everything from line 186 on — including the backfill test at line 460 with its multi-call cursor loop, idempotent rerun, and retention-skip case — hardcodes createMemoryStore(). Scan continuation, ordering, and row-shape differences on Azure Tables or D1 would ship untested through the service's filtering and indexGrant logic, and a regression there would only surface in a real host's maintenance job.
The PR description compounds this: it states tests/listing.test.ts "runs on memory, Azurite and Miniflare D1" and then lists backfill, cursor tampering, retention skipping, and input validation among that coverage. The trace-store does exercise scan on all three backends for snapshots, but not the service's scan-based backfill path.
Checked: grep storeFactories in tests/listing.test.ts confirms the loop bounds; every later test instantiates createMemoryStore() directly.
🔵 Issue 12 — statuses: ["denied"] is accepted by listGrants but can never match anything
packages/agent-access/src/service.ts:1298 · nit · identified by z-ai/glm-5.3-flash
A host filtering listGrants with statuses: ["denied"] gets a valid, permanently empty result: validation accepts every GrantStatus value including "denied" (packages/agent-access/src/service.ts:1294-1301, GRANT_STATUSES at line 85), but the listing loop skips any head without approvedScopes before the status filter, and no grant can transition from approved to denied (approve's deny path requires status "pending"). The docs explicitly say denied requests "are not listed", so the accepted filter value is dead input that silently returns empty pages and will confuse hosts debugging "where are my denied requests".
Checked: grantView emits "denied" only for a head whose status is literally "denied", and such heads always lack approvedScopes, so the approvedScopes === undefined guard at service.ts:1345 excludes them before the filter applies. Either reject "denied" in the filter or document it as accepted-but-never-matching.
🔵 Issue 13 — multipart option validation ignores unknown keys and accepts arrays or other exotic objects
packages/agent-access/src/http.ts:687 · nit · identified by z-ai/glm-5.3-flash
createProtectedResourceAuthenticator({ multipart: { maxsize: 100 } }) (typo) silently enables multipart with the 1 MiB default instead of rejecting the unknown key: a host that believed it raised the bound sees inexplicable 413s, and a host that believed it tightened the bound accepts up to 1 MiB. Likewise multipart: [] or multipart: new Date() passes multipartMaximum (packages/agent-access/src/http.ts:687-700: only null and non-objects are rejected, and arrays are typeof "object") and silently enables the default bound.
This is inconsistent with the package's own strictness: normalizeConfiguration rejects unknown configuration keys, and listGrants/backfillGrantIndex reject unknown input fields via onlyKeys. A one-line key check on the option object fixes it.
🔵 Issue 14 — Multipart tests weakly pin Content-Length validation and never behaviorally test the 1 MiB default
tests/multipart.test.ts:182 · nit · identified by z-ai/glm-5.3-flash
The four malformed Content-Length values ("-1", "1e3", "01", "abc") are sent with body: "x" (tests/multipart.test.ts:180-188), so each request also fails at the multipart parse with 400 regardless; if the runtime dropped or overrode the header, the assertions would still pass, meaning those cases do not actually pin the declared-length validation (only the separate "4096" oversize case pins the mechanism via state.pulled). Separately, the documented 1 MiB default is never exercised behaviorally: the test's DEFAULT_MULTIPART_MAX_BYTES is a local copy compared only against the local ceiling constant (tests/multipart.test.ts:318-320), so an implementation change of the default (e.g., to 10 MiB) would pass the entire suite.
Checked: no test sends a body between 1 MiB and 16 MiB to an authenticator constructed with multipart: {}, so the default bound is asserted only by a tautology of local constants.
🔵 Issue 15 — "Cancels a streamed body" test records state.cancelled but never asserts it
tests/multipart.test.ts:190 · nit · identified by z-ai/glm-5.3-flash
The oversize test asserts only expect(state.pulled).toBeLessThan(20) (tests/multipart.test.ts:198); the cancelled flag its own helper records (tests/multipart.test.ts:58) is never checked. A regression that stops reading at the bound but never cancels/errors the underlying stream (leaving the tee source pending) still passes, while docs/HTTP.md promises "an oversized or unbounded stream is cancelled at the bound with HTTP 413". Note the implementation cancels only the clone's tee branch (the transform error propagates through pipeThrough to the clone source); the original request's stream deliberately stays open, so the test should pin whichever behavior the doc claims.
Checked: grep of tests/multipart.test.ts shows state.cancelled is assigned in countingStream and never asserted anywhere.
🔵 Issue 16 — Dangling owner-index entries from abandoned approvals are permanent and unmanaged
packages/agent-access/src/service.ts:413 · nit · identified by z-ai/glm-5.3-flash
Every approval whose grant transition does not commit — row-cap rejection, request-expiry race, lost acknowledgement, persistent grant-partition conflict, or the approver simply giving up — leaves a permanent member + entry pair in the owner's index partition (write-ahead design, packages/agent-access/src/service.ts:413). Unlike the self-healing case (the same owner retrying the same approval reuses the entry via the member row), an abandoned approval or the cross-owner device-flow race leaves the entry forever, and it consumes one of every page's limit slots: an owner with many dead entries gets progressively emptier pages that the host must still page through, exactly as the "fewer than limit" doc bullet permits but with no remedy.
docs/API.md's cleanup guidance covers only "after a host removes an expired grant partition"; it offers no recipe (and the package no helper) for pruning dangling entries whose grant still exists under another owner or was never approved, so listing quality degrades silently over time.
Checked: indexGrant never deletes rows; listGrants only skips them; grep of docs/API.md shows no dangling-entry cleanup path beyond the removal case.
🔵 Issue 17 — Backfill rejects over-long adapter cursors as invalid_request, contradicting the documented server_error
docs/API.md:196 · nit · identified by z-ai/glm-5.3-flash
docs/API.md:196 states "a malformed adapter cursor fails as server_error", but backfillGrantIndex rejects any cursor longer than 4096 characters with invalid_request (packages/agent-access/src/service.ts:1380-1385) before scan is ever called. A storage adapter whose continuation tokens exceed 4096 characters (some opaque continuation payloads do) makes every backfill page after the first fail with a client-error code for what is a server-side adapter concern, and the documented server_error failure mode never happens for that class of cursor.
Checked: 4096 is the only cursor bound in the service; the cursor is otherwise passed through to this.records.scan untouched. The bound is arbitrary relative to adapter cursor sizes, which cannot be verified here because the adapters are external.
🔵 Issue 18 — HTTP.md overclaims that every multipart rejection carries the WWW-Authenticate challenge
docs/HTTP.md:121 · nit · identified by z-ai/glm-5.3-flash
docs/HTTP.md:121 states "Every rejection carries the usual WWW-Authenticate challenge and no submitted values", but an opted-in multipart request whose service.authenticate fails during current-authority resolution with an outage produces server_error, and resourceError (packages/agent-access/src/http.ts:653-656) returns errorResponse(safe) for server_error without any WWW-Authenticate header. So a 503 rejection of a multipart request carries no challenge, contradicting the sentence a host would implement against.
Checked: the 400/413 multipart rejections themselves do carry the challenge (their code is invalid_request); the gap is specific to the reachable 503 path. Rewording to "every 4xx rejection" would fix it.
🔵 Issue 19 — No test lists a grant in the documented pending state
tests/listing.test.ts:404 · nit · identified by z-ai/glm-5.3-flash
docs/API.md promises listing includes pending ("approved but not yet redeemed") grants, but no test ever produces one: every fixture that creates listed grants (completeDevice/completeAuthorization) polls or exchanges to active, and the revoked/expired test (line 404) revokes before listing, so the statuses tested are only active, revoked, and expired. A regression in grantView's status mapping (e.g., mapping "approved" to "active", or dropping approved-but-unredeemed heads) would pass the suite while the connected-agents page shows wrong or missing entries for freshly approved agents.
Checked: grep of tests/listing.test.ts finds "pending" only in a test title and in invalid-filter inputs; no assertion pins a listed grant with status "pending".
Multipart transport: - Parse Content-Type parameters quote-aware so valid quoted values containing separators are accepted, while keeping exactly-one-boundary and token/quoted boundary validation. - Cancel both body tee branches on every rejection after the multipart headers are examined, so the upload source closes. - Authenticate the bearer again after parsing so revocation, expiry, or authority changes during a slow upload fail closed. - Scan part names for issued credentials, not only values and filenames. - Validate the multipart option strictly: null, non-number, unknown keys, arrays, and non-plain objects fail at construction. Grant listing: - Reject a "denied" status filter, which could never match a listed grant. - Drop the arbitrary backfill cursor length bound; input capture already bounds size and the adapter validates its own continuation. Docs and tests: - Describe the cursor checksum as public and unkeyed, qualify the memory estimate, document upgrade provisioning and dangling-entry pruning, and correct the challenge and backfill cursor error statements. - Run backfill and retention tests on all three storage backends, assert backfill termination, add pending-status, exact 1 MiB default bound, cancellation, slow-upload revocation, quoted-parameter, and header-only Content-Length cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
OpenRouter pull-request review
Verdict: issues
Scope: latest-commit (commit-range)
Mode: verify
Commit: 04f6b306ba51359041a13e94131d0e6364acba41
Judge: openai/gpt-5.6-luna (repaired(canonical+1): source coverage preserved before publication cap)
Cost: $0.1078 (lanes $0.1073 + judge $0.0005) + at least $0.0567 (incomplete)
Lanes
openai/gpt-6.1-sol: ok (1 finding(s), 46.3s, 108394+1953 tokens (80388 cached), 4 tool round(s), via Azure, $0.11)z-ai/glm-5.3-flash: ok (0 finding(s), 798.1s, 1063143+70057 tokens (936979 cached), 24 tool round(s), 1 retried request(s), salvaged finish, via OpenInference, at least $0.0567 (incomplete))
Round 2 resolution
- ✅
r1-1fixed correctly — Oversize rejection leaves the upload source uncancelled: Streamed oversize errors now reach a catch that cancels the unread original request branch, complementing cancellation of the clone branch by the errored transform. Header-bound rejection also cancels the request directly. The declared and streamed oversize tests now assert source cancellation, while the success path preserves the original body. - ✅
r1-3fixed correctly — Incorrect parsing of quoted MIME parameters: The semicolon split was replaced with quote-aware parameter parsing that handles escapes, retains duplicate-boundary detection, and distinguishes token boundaries from quoted boundaries. Added tests cover quoted extension parameters containing semicolons and escaped quotes. - ✅
r1-2fixed correctly — Stale authentication after multipart parsing: Multipart authentication now repeats service.authenticate after parsing and returns that second result. The service's revocation/version fence and completion-time expiry checks therefore apply after the upload. A gated slow-upload test verifies rejection when revocation occurs during parsing. - ✅
r1-9fixed correctly — Multipart part names are not scanned for issued credentials, unlike values and filenames: Multipart entry names are now scanned with ISSUED_CREDENTIAL in addition to credential-field matching and value/filename scanning. The tests include an issued access token used as a part name. - ✅
r1-10fixed correctly — Every approval now hard-depends on a second Storage Core collection; upgrade provisioning is undocumented: docs/API.md now explicitly documents the new collection as an approval dependency, requires explicit-provisioning hosts to grant it read/write/transaction rights before deployment, and explains fail-closed approval behavior when provisioning is missing. - ✅
r1-11fixed correctly — Backfill and most listing behaviors are only exercised on the memory store despite the claimed three-backend coverage: The bounded multi-call backfill, idempotent rerun, subsequent listing/revocation, and retention-skip tests now run inside storeFactories for memory, Azurite, and Miniflare D1. The backfill test also asserts that continuation reaches null. Validation-focused cases remain memory-only, but the previously missing adapter-specific scan and retention coverage is present. - 13 nit finding(s) from earlier rounds retired (severity floor for follow-up rounds is
risk). - Open findings after this round: 1 (0 bug-severity).
Findings
🟠 Issue 1 — Index pruning races with in-flight approvals
docs/API.md:271 · risk · identified by openai/gpt-6.1-sol
A host following the new pruning instructions while approvals are running can remove an index entry for an approval that subsequently succeeds. The approved agent then disappears from listGrants until backfill repairs its index.
approve commits indexGrant before committing the grant-head transition (packages/agent-access/src/service.ts:829). During that interval, the authoritative head can still lack approval or belong to a different principal—the exact conditions the new maintenance instructions treat as safe for deleting both entry: and grant: rows. The approval transition does not recheck or repair those rows afterward. These conditions therefore do not establish that an entry is permanently dangling.
I checked the approval and indexing paths and the dangling-entry and retention tests; none supplies coordination between pruning and approval. Require approval quiescence for this maintenance procedure, or document a safe coordinated cleanup protocol rather than recommending deletion based solely on a head read.
Pruning now skips entries whose grant head is still approvable (pending and unexpired) so it cannot remove the write-ahead entry of an in-flight approval, and each pass finishes with an idempotent backfill that restores any entry removed by a race. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
OpenRouter pull-request review
Verdict: issues
Scope: latest-commit (commit-range)
Mode: verify
Commit: 293e649783bb7b63605ec2de369b143894f5a07c
Judge: openai/gpt-5.6-luna
Cost: $0.0807 (lanes $0.0806 + judge $0.0001)
Lanes
openai/gpt-6.1-sol: ok (0 finding(s), 29.0s, 63454+1033 tokens (46863 cached), 4 tool round(s), via Azure, $0.0621)z-ai/glm-5.3-flash: ok (0 finding(s), 444.2s, 242777+31321 tokens (169608 cached), 11 tool round(s), via OpenInference, $0.0185)
Round 3 resolution
⚠️ r2-1fixed incorrectly — Index pruning races with in-flight approvals: The new instructions protect unexpired pending requests, but pruning can still remove an entry for an approval that subsequently commits. An approval can finish indexing and pass its expiry check just before the request deadline, then wait on its grant transaction. After the deadline, maintenance can read the still-pending head, delete the index rows under step 3, and complete backfill before the …- Open findings after this round: 1 (0 bug-severity).
No structured findings from the successful lane(s).
An approval's grant transaction can commit shortly after the request deadline because the deadline is checked before the transaction is sent, and the owner index and grant partitions cannot be updated atomically. Pruning therefore treats pending heads as in flight until expiry plus a grace period longer than the host's approval and storage timeouts, and relies on recurring idempotent backfill to repair any residual race. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
OpenRouter pull-request review
Verdict: clean
Scope: latest-commit (commit-range)
Mode: verify
Commit: ce7ad6b565dd1c1dc37529b8b074e80978170374
Judge: openai/gpt-5.6-luna
Cost: $0.0596 (lanes $0.0595 + judge $0.0001)
Lanes
openai/gpt-6.1-sol: ok (0 finding(s), 21.3s, 53758+694 tokens (40392 cached), 4 tool round(s), via Azure, $0.0488)z-ai/glm-5.3-flash: ok (0 finding(s), 86.1s, 155024+8930 tokens (132608 cached), 11 tool round(s), via InferenceNet, $0.0107)
Round 4 resolution
- ✅
r2-1fixed correctly — Index pruning races with in-flight approvals: The maintenance guidance no longer presents pruning as race-free. It requires a grace period beyond approval/storage timeouts, recurring backfill rather than a single post-pruning pass, and explicitly warns that a residual race can temporarily remove a grant fromlistGrants. Hosts unable to schedule recurring backfill are told not to prune.
Checked approve, the pre-transaction deadline guard …
- Open findings after this round: 0 (0 bug-severity).
No structured findings from the successful lane(s).
Summary
Two host-facing additions. Neither changes existing default behavior or the package version.
1. Owner-scoped, paginated grant discovery
Hosts that render a connected-agents page previously had only keyed
getGrant/revokeGrant, so each host had to keep its own owner-to-grant index. This adds:listGrants(browserContext, { ownerPrincipal, cursor?, limit?, statuses? })returning{ grants, nextCursor }backfillGrantIndex({ cursor?, limit? })returning{ scanned, indexed, nextCursor }(host maintenance)Behavior
getGrant.ownerPrincipalmust equal the trusted session principal, otherwise the call fails withaccess_denied. A non-string, empty, control-character or over-512-character principal isinvalid_request, and so are unknown fields.limitdefaults to 20, max 100. A page costs one owner-index head read, at mostlimitentry reads and at mostlimitgrant-head reads. It never scans or enumerates. Order is newest indexed first.pgc1.<ownerPartition>.<position>.<check>string. A cursor from another owner, an altered position or check, or a malformed value is rejected withinvalid_requestand the error carries no content. The cursor is not a secret and never authorizes anything: every page re-verifies the session, and the position is clamped to the current owner head.GrantViewthatgetGrantreturns (one shared projection). Hashes, fingerprints, PKCE challenges, redirects and raw records are never included.pending(approved but not yet redeemed),active,revoked,expired. Each carries its current status. Owned requests that were never approved, and denied requests, are not linked agents and are not listed;getGrantstill reads them. The optionalstatusesfilter (e.g.["active"]) narrows a page after reading, so a page can hold fewer thanlimititems whilenextCursoris non-null.Design choice: write-ahead owner index in its own collection
A grant's partition is its random (or user-code-derived) locator, and the owner may not be known until approval. An efficient owner scan is therefore impossible without a schema change. Storage Core
transactis strictly single-partition, and AGENTS.md forbids claiming cross-partition atomicity. So the index cannot share the grant's transaction. Instead:agent-access.owner-index.v1, with one partition per SHA-256 of(issuer, resource, owner). Each partition holds aheadsequence counter, plus agrant:<id>membership row and anentry:<seq>row per indexed grant. All three are written in one owner-partition transaction (CAS on the head, inserts for the other two). The membership row makes indexing idempotent.approvecommits the owner entry before the grant's approval transition. Every committed approval therefore has an entry. If the approval then conflicts, is refused or has an unknown outcome, a dangling entry may remain. That is harmless because listing re-reads each authoritative grant head and returns it only when owner, issuer and resource match. A test approves the same device grant as a second administrator after the first administrator's approval failed after indexing, and confirms that neither owner sees the other's grant.revokeGrantis tested end to end.Compatibility. Grants approved before this change have no index entries. They keep working through
getGrant,revokeGrantand every token path, but are not listed until the host runsbackfillGrantIndex. That call is a bounded (default 100, max 1000 rows per call), idempotent pass over Storage Core's authoritativescan. No schema change touchesagent-access.records.v1. Index entries whose grant was removed by host retention are skipped. The docs explain how to delete them and warn against deleting an ownerheadrow.2. Opt-in, bounded multipart bearer transport
createProtectedResourceAuthenticator({ service, configuration, multipart: { maxBytes? } }):maxBytesdefaults to 1 MiB and has a hard ceiling of 16 MiB. An invalid bound throwsOAuthErrorat construction. Withoutmultipart, multipart bodies are still rejected exactly as before, and URL-encoded forms are still rejected in every mode.boundary, and a well-formedContent-Lengththat is within the bound (otherwise 413 before any byte is read). Next, theAuthorization: Bearerheader is authenticated as usual, so a missing or invalid bearer gets its 401 challenge and the body is never pulled. Only then is the body parsed, after which the bearer is authenticated again, so revocation, expiry or authority changes during a slow upload fail closed.request.clone()through a byte-countingTransformStreaminto the runtime's ownResponse.formData()parser. A stream over the bound errors and is cancelled at the bound with 413. The parsedFormDatacomes back asresult.form(ProtectedResourceAccess extends DelegatedAccess), so the host does not have to parse twice. The originalRequeststays unread for hosts that prefer to read it themselves. The docs note the memory cost: about twicemaxBytesper in-flight simple file upload, because the tee keeps the unread original. That is not a general bound, since parsed-form overhead grows with part count.access_token,refresh_token,id_token,client_secret,client_assertion,client_assertion_type,device_codeorcode_verifier(case-insensitive) is rejected with 400invalid_request. So is any part name, text value or filename containing an issued Agent Access credential. Queryaccess_tokenis still rejected. File contents are not scanned (documented).invalid_request. Declared or streamed oversize gives 413invalid_request. All rejections keep the existingWWW-Authenticatechallenge,no-storeheaders and content-free bodies.Tests
tests/listing.test.ts:statusesvalidation (including the rejecteddeniedfilter); browser authority and outage; an approved-but-unredeemed grant listed aspendingand thenactive; revoked/expired handling with unapproved/denied omission.tests/multipart.test.tscovers:;accepted; malformed parameters rejected); malformed multipart and boundary cases.null, non-number, unknown key, array, non-plain object).tests/storage.test.tsnow asserts the separate owner-index collection and its single-partition transactions alongside the existing grant-transaction invariants.Local gate (Windows, Node 24.18.0,
CI=1)pnpm run format:check: passpnpm run check: passpnpm test: pass. 153 vitest tests across 6 files (memory, Azurite, Miniflare D1), andtest:releasewith 133 passed, 0 failed, 3 skippedpnpm run release:check: pass. The runtime export list is unchanged: the new page-size and multipart bound constants stay internal and are documented by value.pnpm run example: passThe Node 22 lane runs in CI only, because no local Node 22 install is available.
Docs
README, package README,
docs/API.md(new Owner grant listing section, operation table, retention note),docs/HTTP.md(new Opt-in multipart uploads section) anddocs/ARCHITECTURE.md(owner index trust model). The repo has no changelog. No version bump, tag or publish.🤖 Generated with Claude Code