Skip to content

feat(core): expose canGrant as a queryable narrowing check - #104

Merged
Mearman merged 1 commit into
mainfrom
feat/can-grant-query
Sep 13, 2026
Merged

feat(core): expose canGrant as a queryable narrowing check#104
Mearman merged 1 commit into
mainfrom
feat/can-grant-query

Conversation

@Mearman

@Mearman Mearman commented Sep 13, 2026

Copy link
Copy Markdown
Member

mintCapabilityToken already enforced every one of tokens.cddl's own delegation-narrowing rules (bearer match, expiry within parent, scope narrows, same capability, delegations-remaining strictly less than parent's), but only as a side effect of actually attempting a mint. Extracts that arithmetic into checkNarrowing, shared by mintCapabilityToken and a new canGrant(heldToken, deviceId, candidate, now) pure query, so a caller can ask whether a delegation would succeed without attempting (and potentially failing) a real mint, and the two can never silently drift into different ideas of what narrows a token.

canGrant's signature extends the issue's own originally-sketched (heldToken, capability, scope) to also take the querying device-id (needed for the bearer-match check mint itself performs) and now (needed to reject an already-expired candidate the same way mint's own first check does) -- both genuinely required for the query to agree with what a real mint attempt would actually decide, not optional extras.

Closes #79.

mintCapabilityToken already enforced every one of tokens.cddl's own delegation-narrowing rules (bearer match, expiry within parent, scope narrows, same capability, delegations-remaining strictly less than parent's), but only as a side effect of actually attempting a mint. Extracts that arithmetic into checkNarrowing, shared by mintCapabilityToken and a new canGrant(heldToken, deviceId, candidate, now) pure query, so a caller can ask whether a delegation would succeed without attempting (and potentially failing) a real mint, and the two can never silently drift into different ideas of what narrows a token.

canGrant's signature extends the issue's own originally-sketched (heldToken, capability, scope) to also take the querying device-id (needed for the bearer-match check mint itself performs) and now (needed to reject an already-expired candidate the same way mint's own first check does) -- both genuinely required for the query to agree with what a real mint attempt would actually decide, not optional extras.
@Mearman
Mearman marked this pull request as ready for review September 13, 2026 05:20
@Mearman
Mearman merged commit bf66f1f into main Sep 13, 2026
8 checks passed
@Mearman
Mearman deleted the feat/can-grant-query branch September 13, 2026 05:20
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 13, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review Completed 2026-09-13T05:25:23.407097Z 238121a Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

core/tokens: expose canGrant() as a queryable narrowing check

1 participant