Skip to content

fix(tangle): never cache or share single-use broker tokens - #579

Merged
drewstone merged 10 commits into
mainfrom
fix/single-use-broker-token-provider
Sep 14, 2026
Merged

drewstone merged 10 commits into
mainfrom
fix/single-use-broker-token-provider

Conversation

@drewstone

@drewstone drewstone commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Problem

A broker bearer authorizes one Hub execution. Caching it for its TTL or sharing an in-flight mint gives concurrent or later executions a token another request has consumed.

Implementation

Mint independently on every getToken() call. Remove both bearer caching and in-flight sharing. Preserve API compatibility: deprecated refreshSkewMs/now options are inert; invalidate() remains callable and cannot revoke authoritative grants. Mint failures propagate without retrying external actions. No dependencies, alternate Hub client or runtime redesign.

Tests cover out-of-order concurrent completion, unique tokens per consuming execution, burst uniqueness, issuer errors, exact mint inputs and legacy options. Generated API docs/codemap were regenerated with the maintained generator, not hand-edited.

Verification — latest head

Complete Verify PR workflow passed at 1f8cea4e0cb95e20bec95e82737f35d9639e137c.

Run: https://github.com/tangle-network/agent-app/actions/runs/34728075883

Includes frozen dependency installation; generated documentation and clean-doc diff; typecheck; test:gates; build; the complete Vitest suite; generated-application tests; and knip. Read-only CI uses SHA-pinned actions and stores verification archives outside the dependency-audited source tree.

The earlier before/after reproduction failed 5 of 10 checks before the fix and passed all 10 after. Full repository CI now supersedes the former local-only limitation.

Companion work

No live token minting, paid-number purchase, production deployment, merge or package release was performed. This is a non-draft implementation PR; live activation is a separate operational gate.

@drewstone
drewstone marked this pull request as ready for review September 12, 2026 22:14
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 12, 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
📝 Code Review Completed 2026-09-12T22:17:22.770406Z 6035d62 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6035d62395

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/verify-pr.yml Outdated
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Align the PR workflow with the repository Node pin

Pin this pull-request workflow to .nvmrc rather than Node 22. resolveNodeRequirement() scans every workflow triggered by pull_request and explicitly refuses when its major differs from .nvmrc; with .nvmrc at 24.18.0, every required pnpm signoff --source head invocation now exits before running any checks.

AGENTS.md reference: AGENTS.md:L88-L90

Useful? React with 👍 / 👎.

Comment thread .github/workflows/verify-pr.yml Outdated
env:
NODE_OPTIONS: --max-old-space-size=12288
steps:
- uses: actions/checkout@v4

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Pin all workflow actions to immutable SHAs

Replace the version tags here and on the other three uses: entries with the repository's required 40-character action SHAs. On every post-merge publish run, Check release contract invokes .github/scripts/test-publish-workflow.mjs, which scans all workflow files and exits unless every action reference is an exact SHA; this new actions/checkout@v4 alone reproduces publish workflow contract failed: every action must use an exact commit SHA, blocking the release before source verification or packaging.

Useful? React with 👍 / 👎.

Comment thread .github/workflows/verify-pr.yml Outdated
Comment on lines +37 to +38
pnpm docs:gen
git diff -- docs > verification/generated-docs.patch

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Check documentation freshness before mutating the tree

Run the generator in check mode, or fail when this diff is nonempty, rather than regenerating before the tests. For a commit with stale generated documentation—as this one is, since docs/api/tangle.md still documents cached tokens—pnpm docs:gen silently repairs the runner's working tree and the redirected git diff still exits successfully, so the later codemap-freshness test sees updated files and the workflow reports green even though the exact committed HEAD fails the required sign-off.

AGENTS.md reference: AGENTS.md:L88-L90

Useful? React with 👍 / 👎.

@drewstone
drewstone merged commit c45c16f into main Sep 14, 2026
1 check passed
@drewstone
drewstone deleted the fix/single-use-broker-token-provider branch September 14, 2026 00:52
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.

1 participant