Skip to content

fix(interop)!: forbid double-dot inside interop segments (LAB-5906) - #94

Merged
27Bslash6 merged 3 commits into
mainfrom
lab-5906-interop-forbid-double-dot
Sep 30, 2026
Merged

27Bslash6 merged 3 commits into
mainfrom
lab-5906-interop-forbid-double-dot

Conversation

@27Bslash6

@27Bslash6 27Bslash6 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Interop segments (namespace and operation) may no longer contain ... The segment regex ^[a-z0-9][a-z0-9._-]{0,63} admits .., but the CachekitIO server rejects ..anywhere in a key. As a result, every SDK accepted a segment such asa..band produced keys that returned400` on CachekitIO, while the same keys worked on Redis and file backends.

The regex is unchanged and still uses no lookahead. The ban is a separate substring check that applies on every backend, following the same pattern as the ns / nsapi namespace reservation.

Modified public surfaces

spec/interop-mode.md

  • Segment grammar: adds a normative MUST NOT for .. in either segment. A lone . stays valid, including a trailing one (app.).
  • SDK requirement 1: now includes the .. rule.
  • Status banner and SaaS Considerations: the "except .." caveat is removed. The grammar is now described as a strict subset of what the server validator accepts.
  • Test Vectors table: key_vectors goes from 34 to 35 and error_vectors from 11 to 13.

test-vectors/interop-mode.json (1.1.0 → 1.2.0)

  • Error vector reject_double_dot_namespace: namespace a..b, with .. mid-segment.
  • Error vector reject_double_dot_operation: operation x.., with .. at the end. This catches implementations that skip the final character pair.
  • Key vector lone_dots_stay_valid: namespace app., operation users.fetch.by_id, args [1]. It reuses the args hash 405f09…e21a from reservation_scope, so only the key string differs. It is the first key vector with a . in a segment.
  • segment_pattern is unchanged. segment_pattern_note now states the .. rule.

tools/interop-reference.py

  • Adds the constant FORBIDDEN_SUBSTRING = "..".
  • interop_key() now raises InteropError for a segment containing ... The check runs per segment, after the pattern match and before the reserved-namespace check.
  • _build() emits version 1.2.0 and the new vectors.
  • _self_check() asserts that both new error vectors match segment_pattern. This ensures they test the new rule rather than the regex.

tools/interop-crosscheck.mjs

  • Adds a segmentValid() helper that combines the pattern test with !segment.includes("..").
  • The rule is hard-coded from the spec rather than read from the fixture, matching how the reserved namespaces are handled.

Other files

  • changelog.d/20260930_lab-5906.md: new fragment that includes a "Breaking for" note.

Breaking change

Any interop namespace or operation containing .. now fails at decoration or registration time in every SDK, on every backend. To migrate, rename the segment; the keys it names become a full cache miss. Such keys already failed on CachekitIO before this change.

Merge order

Merge this PR before the SDK PRs. Each SDK PR vendors the 1.2.0 fixture byte-for-byte and pins its sha256.


This PR updates documentation for the interop change that forbids .. inside segments (fixture 1.2.0). Only the changelog.d/20260930_lab-5906.md and sdk-feature-matrix.md diffs are included here. The breaking change named in the PR title (spec, fixtures and tools) is not in the supplied patches; it is referenced only through the existing changelog entries.

Changes in sdk-feature-matrix.md ("Test vectors in CI" row)

  • Python (cachekit-py):
    • Fixture 1.1.0 (ns/nsapi namespace reservation) is now recorded as shipped in PyPI 0.20.0 (cachekit-py#350). It was previously listed as unreleased.
    • Adds fixture 1.2.0 (no .. in a segment) via cachekit-py#391, unreleased.
  • Rust (cachekit-rs): Adds fixture 1.2.0 via cachekit-rs#98, unreleased.
  • TypeScript (cachekit-ts): Adds fixture 1.2.0 via cachekit-ts#164, unreleased.
  • All other cells in the row are unchanged.

Changes in changelog.d/20260930_lab-5906.md

  • Adds an entry for the matrix update above:
    • The SDK PRs that vendor fixture 1.2.0 are linked, and none is released yet.
    • The Python cell now reflects fixture 1.1.0 shipping in PyPI 0.20.0.

Public API impact

  • These patches change no code or public APIs; they are documentation and changelog updates only.

Summary

The interop/v1 segment pattern ^[a-z0-9][a-z0-9._-]{0,63}$ admits .. inside a segment (a..b, users.v1..beta). The server rejects .. anywhere in a key (cache-key-format.md → Server-Side Requirements, the Traversal row). So every SDK accepted such a segment and minted a key that fails with 400 on every CachekitIO request, while the same key works on Redis and file backends.

This PR forbids .. in either segment, on every backend: interop keys are portable, so a segment valid on one backend must be valid on all. That is the same rule the ns / nsapi reservation follows. The pattern itself is unchanged and stays a plain regex without lookahead, so each SDK can apply it as written; the ban is a separate substring check. The : delimiters separate the segments and the hash is hex, so a per-segment check covers the whole key.

Changes

  • spec/interop-mode.md: Segment grammar says a segment MUST NOT contain .., with the reason; a lone . stays valid, including at the end of a segment. SDK requirement 1 names the rule. The status banner and SaaS Considerations drop the "one known exception" text, since the grammar is now a plain subset of what the server accepts. Test Vectors counts: 35 key, 13 error.
  • test-vectors/interop-mode.json 1.2.0:
    • reject_double_dot_namespace: namespace a..b (the .. mid-segment).
    • reject_double_dot_operation: operation x.. (the .. at the end of the segment, which a check that skips the last pair misses).
    • lone_dots_stay_valid: namespace app., operation users.fetch.by_id. No key vector had a . in a segment before, so an SDK that rejected every ., or a trailing ., passed the whole suite.
    • segment_pattern is unchanged; segment_pattern_note states the rule.
  • tools/interop-reference.py rejects a .. segment. Its self-check asserts that both new error vectors match segment_pattern, so they exercise the new rule and not the pattern.
  • tools/interop-crosscheck.mjs hard-codes the rule rather than reading it from the fixture, as it does for the reserved namespaces.
  • changelog.d/20260930_lab-5906.md: the entry, with a Breaking for line. CHANGELOG.md is untouched.
  • sdk-feature-matrix.md: the "Test vectors in CI" row names fixture 1.2.0 and the SDK PRs that vendor it.

Breaking

An interop namespace or operation containing .. now raises at decoration / registration time in every SDK, on every backend. Rename the segment; the keys it names become a full cache miss. Before this change, such a key already failed on CachekitIO.

Merge order

Merge this PR before the three SDK PRs. Each SDK PR vendors test-vectors/interop-mode.json byte-for-byte (sha256 702613766d1b92bc3a337627a96b9aedc89abfeb4d9208c2bb00c9539a0a1f40) and pins that sha.

Test plan

  • python3 tools/interop-reference.py verify (stdlib, and again with cryptography + msgpack): 35 key, 4 value, 13 error, 1 AAD, 1 encryption.
  • node tools/interop-crosscheck.mjs with @noble/hashes@2.2.0: all vectors verified independently.
  • Mutations of the cross-check fail loudly: no .. check (both error vectors fail), reject any ., skip the last pair, reject empty labels after splitting on ., reject a trailing .. Removing the reference tool's check fails its self-check.
  • Every other verify.yml command passes locally, including tools/test_changelog_collect.py and the CHANGELOG.md-untouched check.

The segment pattern admits `..` inside a segment (`a..b`, `users.v1..beta`),
but the server rejects `..` anywhere in a key (cache-key-format.md,
Server-Side Requirements, Traversal row). Every SDK therefore accepted such a
segment and minted a key that fails with 400 on every CachekitIO request,
while the same key works on Redis and file backends. Interop keys are
portable, so the grammar forbids it on every backend, the same rule the
ns/nsapi reservation follows.

The pattern stays a plain regex without lookahead, so every SDK can apply it
as written; the ban is a separate substring check. A `..` cannot span the `:`
delimiter because a segment cannot start with `.`, so a per-segment check
covers the whole key.

Fixture 1.2.0 adds reject_double_dot_namespace (a..b),
reject_double_dot_operation (x..y) and the key vector lone_dots_stay_valid
(app.v1 / users.fetch.by_id): before it, no key vector had a `.` in a
segment, so an SDK that rejected every `.` passed the suite.

BREAKING CHANGE: an interop namespace or operation containing `..` now raises
at decoration / registration time, on every backend. Rename the segment.
…5906)

reject_double_dot_operation now puts the `..` at the end of the segment
(`x..`): a byte loop that skips the last pair still rejects `a..b` and
`x..y`, but accepts `abc..`. The namespace vector keeps the mid-segment case.

lone_dots_stay_valid now uses namespace `app.`: an implementation that splits
on `.` and rejects empty labels, or rejects a trailing `.`, passed every
vector before, although the grammar allows a trailing `.`.

The comments now give the right reason a per-segment check covers the key:
the `:` delimiters separate the segments and the hash is hex, so any `..` lies
inside one segment.
@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 38 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: cachekit-io/protocol/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 07b82367-e8da-485d-9ee8-13ba0b11096b

📥 Commits

Reviewing files that changed from the base of the PR and between 23e36ba and 8c547ed.

📒 Files selected for processing (6)
  • changelog.d/20260930_lab-5906.md
  • sdk-feature-matrix.md
  • spec/interop-mode.md
  • test-vectors/interop-mode.json
  • tools/interop-crosscheck.mjs
  • tools/interop-reference.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kodus-27b

kodus-27b Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the `@kody start-review` command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Providing Context (Files & MCPs)

Add these hints in your PR description (or a comment) to unlock deeper checks:

  • Ticket / Acceptance Criteria: `Refs: ABC-123` (Linear/Jira/Asana/ClickUp/Trello) or a direct ticket link.
  • Bugfix Validation: a Sentry/Datadog/Bugsnag event link (or paste the stack trace/error message).
  • Endpoint Risk: mention the route (e.g., `POST /api/payments`) or controller/action name.
  • Attach a repo file as context: use an explicit marker like `@file:docs/guide.mdx#L10-L50` (replace with your real path).
  • API Contract Docs: include `@file:openapi.yaml` or `@file:swagger.json` when changing routes/schemas.
  • Definition of Done / Standards: include `@file:DOD.md` or `@file:CONTRIBUTING.md` if your repo has them.
  • Design System Source of Truth: include `@file:ui/index.ts` (replace with your DS entrypoint path).
  • Feature Flags: include the flag key/name and `@file:flags.ts` / `@file:config.json` (and optionally the PostHog flag name).
  • Edge/CDN Rules: link the Cloudflare rule/zone or describe the intended redirect/header behavior.
  • Attach an MCP tool output: use `@mcp<provider|tool>` (replace with an installed MCP provider + tool, e.g., `@mcp<sentry|events.search>`).
Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

Kody Code Review — 1 suggested fix.
Paste the prompt below to your agent and all review fixed at once!

🛠️ Open Agent Prompt
A code review identified the following issues in this pull request.
Each section describes what was found and includes a reference implementation where available.

Files involved:
- tools/interop-reference.py:900

---

### [1/1] tools/interop-reference.py:900
Issue identified during code review:
Stripped validation in the '..' vector self-check in tools/interop-reference.py: the bare `assert` verifying `SEGMENT_RE.fullmatch(ev["namespace"])` and `SEGMENT_RE.fullmatch(ev["operation"])` is removed when Python runs with optimizations enabled, unlike the surrounding checks that use an explicit `raise AssertionError(...)`. When the script runs under `python -O`, the check is skipped and vectors that fail `segment_pattern` are emitted without error. Fix: replace the `assert` with `if not (SEGMENT_RE.fullmatch(ev["namespace"]) and SEGMENT_RE.fullmatch(ev["operation"])): raise AssertionError(f"{name} must match segment_pattern so it exercises the '..' rule")`.

---

Review each issue in context, use the reference implementations as guidance, and apply fixes that are consistent with the surrounding codebase.

Comment thread tools/interop-reference.py
…-5906)

The Test vectors in CI cells name fixture 1.2.0 and cachekit-py#391, cachekit-rs#98 and cachekit-ts#164, all unreleased. The Python cell says fixture 1.1.0 ships in PyPI 0.20.0, which is published.
@kodus-27b

kodus-27b Bot commented Sep 30, 2026

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the `@kody start-review` command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Providing Context (Files & MCPs)

Add these hints in your PR description (or a comment) to unlock deeper checks:

  • Ticket / Acceptance Criteria: `Refs: ABC-123` (Linear/Jira/Asana/ClickUp/Trello) or a direct ticket link.
  • Bugfix Validation: a Sentry/Datadog/Bugsnag event link (or paste the stack trace/error message).
  • Endpoint Risk: mention the route (e.g., `POST /api/payments`) or controller/action name.
  • Attach a repo file as context: use an explicit marker like `@file:docs/guide.mdx#L10-L50` (replace with your real path).
  • API Contract Docs: include `@file:openapi.yaml` or `@file:swagger.json` when changing routes/schemas.
  • Definition of Done / Standards: include `@file:DOD.md` or `@file:CONTRIBUTING.md` if your repo has them.
  • Design System Source of Truth: include `@file:ui/index.ts` (replace with your DS entrypoint path).
  • Feature Flags: include the flag key/name and `@file:flags.ts` / `@file:config.json` (and optionally the PostHog flag name).
  • Edge/CDN Rules: link the Cloudflare rule/zone or describe the intended redirect/header behavior.
  • Attach an MCP tool output: use `@mcp<provider|tool>` (replace with an installed MCP provider + tool, e.g., `@mcp<sentry|events.search>`).
Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

@27Bslash6
27Bslash6 merged commit 7bb8727 into main Sep 30, 2026
4 checks passed
@27Bslash6
27Bslash6 deleted the lab-5906-interop-forbid-double-dot branch September 30, 2026 05:59
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