Skip to content

Trusted-endpoint patterns + API key onboarding docs + drop cluster_b leftover#19

Merged
aural-psynapse merged 4 commits into
mainfrom
chore/drop-cluster-b-helper-v2
May 6, 2026
Merged

Trusted-endpoint patterns + API key onboarding docs + drop cluster_b leftover#19
aural-psynapse merged 4 commits into
mainfrom
chore/drop-cluster-b-helper-v2

Conversation

@aural-psynapse
Copy link
Copy Markdown
Contributor

Linear-history rebase of #17 (the original branch had a merge commit; the repo only allows rebase merges). Same content, approved, just replayed cleanly on top of main. Closes #14, supersedes #17.

1. trusted_endpoints: {id} and {path:path} placeholders

Registered URLs may now contain FastAPI/Express-style path placeholders:

Placeholder Matches Example
{name} exactly one path segment /customers/{id} matches /customers/42 but not /customers/42/orders
{name:path} any subtree /customers/{rest:path} matches both above

Plain URLs without { keep exact-match semantics — zero migration. is_trusted_endpoint exact match first (fast path); only scans pattern entries on a miss. The snapshot tamper-check honors the same syntax.

12 new tests.

2. README: API key onboarding

Short "Getting PROVABLY_API_KEY and PROVABLY_ORG_ID" subsection — sign up at app.provably.ai, create org, Integrations menu. Plus a link to provably.ai/docs.

3. Drop default_cluster_b_url() + CLUSTER_B_URL

BREAKING for callers importing default_cluster_b_url or passing cluster_b_url=... as a keyword arg. Helper + env var were leftovers from the langgraph-demo monorepo with a localhost:8082 default. Configuration of where YOUR verifier lives belongs in your application. post_handoff(receiver_url, payload) (positional arg renamed) takes the URL directly.

Verified no usages in verifiable-state-demo or customer-support-sdk-demo.

Verification

  • 116/116 tests pass
  • Ruff clean

… registered URLs

A registered URL may now contain FastAPI/Express-style path placeholders so a
single entry covers a family of concrete URLs:

  {name}        - matches exactly one path segment (no '/').
                  e.g. https://api.example.com/customers/{id} matches
                  /customers/42 but NOT /customers/42/orders.

  {name:path}   - matches any subtree, including '/' separators.
                  e.g. https://api.example.com/customers/{rest:path} matches
                  both /customers/42 and /customers/42/orders.

Closes #14.

Why: customer-support-sdk-demo had to enumerate ~70 concrete URLs at startup
for templated routes (/customers/{id}). Runtime-generated ids (e.g. POST
/tickets returning a fresh id) couldn't be trusted until manually registered.
A single placeholder entry replaces the enumeration.

Implementation:

- Plain URLs without '{' keep exact-match semantics. No schema change. No
  migration needed for existing rows. Existing exact-match tests unchanged.
- Pattern matching is auto-detected from URL content. Pattern compilation is
  LRU-cached so repeated lookups don't recompile the regex.
- is_trusted_endpoint uses a two-phase lookup: exact match first (single
  indexed query, fast path), then a pattern-only scan (LIKE '%{%' filter)
  for rows containing placeholders. Plain registries see no perf regression.
- The snapshot tamper-check inside check_claim_endpoints_are_trusted honors
  the same syntax — a payload built against a pattern entry verifies cleanly
  on the receiver side.

Tests: 12 new (94 total). Ruff clean.
…G_ID

New 'Getting PROVABLY_API_KEY and PROVABLY_ORG_ID' subsection under Configuration:

  1. Sign up at app.provably.ai
  2. Create an organisation (org id shown in the URL)
  3. Left-side menu → Integrations → create one (generated key)

Plus a pointer to provably.ai/docs for full product documentation.

Closes the gap surfaced while users were trying to find where these values come
from — the env-var table told them they were required but not where to source them.
…h-demo leftover)

`default_cluster_b_url()` was extracted verbatim from the langgraph-demo
monorepo (per CHANGELOG: 'Initial extraction from the langraph-demo monorepo').
Two problems:

1. The localhost:8082 default presumes a specific deployment shape (the
   original two-cluster demo); it is meaningless to a fresh SDK user.
2. 'cluster B' is internal terminology a user reading the SDK has no way to
   understand without context.

Configuration of where YOUR receiver lives belongs in your application, not
the SDK. `post_handoff` already takes the URL as a positional arg — drop
the convenience helper, drop the env var, rename the arg from
`cluster_b_url` to `receiver_url` for clarity.

Breaking for callers that import `default_cluster_b_url` or pass
`cluster_b_url=...` as a keyword arg. CHANGELOG entry added.
@aural-psynapse aural-psynapse merged commit fe7c5a7 into main May 6, 2026
4 checks passed
@aural-psynapse aural-psynapse deleted the chore/drop-cluster-b-helper-v2 branch May 6, 2026 13:59
SimoneBottoni pushed a commit that referenced this pull request May 11, 2026
…rl_allowlist

Parity with the trust gate from PR #19. Reuses the `_matches_registered`
helper from `trusted_endpoints.py` instead of duplicating regex logic, so
both code paths share one matcher.

Implementation:

- `set_intercept_url_allowlist` keeps storing entries as a normalized set
  (no schema change). Pattern detection is by URL content; auto-applied.
- New private `_url_in_allowlist(nurl)` does exact set membership first
  (O(1)), then iterates only the pattern entries (those containing `{`)
  on a miss. Plain-URL allowlists pay no per-request iteration cost.
- The two callsites in `_record_and_maybe_tamper` (recording gate +
  tamper-hook gate) collapse into one `in_allowlist` boolean to avoid
  computing the membership twice.

Closes #20.

5 new unit tests covering: pattern matches concrete URL, single-segment
placeholder rejects extra segments, `{rest:path}` covers subtree, mixed
exact+pattern allowlist retains per-entry semantics, plain URLs still
exact-only (no accidental prefix match).

121/121 tests pass (was 116, +5).
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.

trusted_endpoints: support prefix / pattern match (not exact-only)

1 participant