Skip to content

Jurisdiction#79

Merged
steflsd merged 2 commits into
mainfrom
feat/supported-countries-registry
Jul 17, 2026
Merged

Jurisdiction#79
steflsd merged 2 commits into
mainfrom
feat/supported-countries-registry

Conversation

@steflsd

@steflsd steflsd commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Presidio detection can now be scoped to supported countries at deployment time.
    • Configured entity lists narrow detection; when unset, detection uses the deployed recognizer registry.
    • Development builds automatically receive a Git-based build identifier.
  • Changes

    • Removed per-chat jurisdiction controls and request-level detection-profile overrides.
    • UK-specific recognizers are excluded unless the UK is enabled.
    • Internal control headers are no longer forwarded upstream.
  • Documentation

    • Updated setup, configuration, and PII detection guidance.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 31 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 19586825-7b65-4cd4-97e4-3c63cdb84ecf

📥 Commits

Reviewing files that changed from the base of the PR and between f2f65cc and 13ecfda.

📒 Files selected for processing (7)
  • .changeset/supported-countries-registry.md
  • apps/gateway/src/components/chat/ChatView.tsx
  • apps/gateway/src/components/chat/IssueReportDialog.tsx
  • packages/ficta/presidio/default_recognizers.yaml
  • packages/ficta/presidio/ficta_presidio/service.py
  • scripts/dev-env.mjs
  • scripts/dev-runner.mjs

Walkthrough

The PR replaces request-level detection jurisdictions with Presidio sidecar load-time country scoping, removes related gateway, storage, engine, protocol, and UI plumbing, broadens internal header stripping, updates verification coverage, and derives development build IDs from Git when unset.

Changes

Presidio country-scoped registry

Layer / File(s) Summary
Country-scoped recognizer loading and verification
packages/ficta/presidio/*, packages/ficta/scripts/verify-presidio-sidecar.mts, packages/ficta/src/engine/plugins/pii/presidio-recognizer.ts, packages/ficta/test/presidio.test.ts, scripts/dev-runner.mjs
Presidio filters country-tagged recognizers at startup, uses optional entity allowlists for narrowing, and verifies the scoped entity surface and analysis behavior through sidecar APIs.
Deployment documentation and registry updates
apps/gateway/README.md, packages/ficta/README.md, packages/ficta/docs/plugins.md, docker-compose.sidecars.yml, .changeset/supported-countries-registry.md
Examples and release notes reference default_recognizers.yaml and document FICTA_PRESIDIO_SUPPORTED_COUNTRIES, load-time scope, and optional entity narrowing.

Gateway jurisdiction contract removal

Layer / File(s) Summary
Chat and API removal
apps/gateway/src/components/chat/*, apps/gateway/src/routes/*, apps/gateway/src/lib/model-adapter.ts, apps/gateway/src/lib/protection-preview.ts
Chat UI, thread creation, protection previews, and model adapter headers no longer carry detection jurisdictions or detection profiles.
Storage and database removal
apps/gateway/src/lib/storage/*, apps/gateway/drizzle/*, apps/gateway/test/storage.test.ts
Thread schemas, persistence methods, summaries, migrations, and jurisdiction persistence tests remove the detection_jurisdictions contract.
Protocol surface removal
packages/protocol/src/index.*
Detection-profile headers, jurisdiction types, supported-jurisdiction constants, and validation helpers are removed from the protocol exports.

Engine and proxy profile removal

Layer / File(s) Summary
Request scope and ticket flow
packages/ficta/src/engine/*, packages/ficta/src/server.ts
Request scopes, keyed-scope cache invalidation, detector contexts, and protection-ticket validation no longer use detection profiles or profile fingerprints.
Proxy header filtering and regression coverage
packages/ficta/src/server.ts, packages/ficta/test/loopback-multiturn.test.ts, packages/ficta/test/protection-preview.test.ts, packages/ficta/test/scope.test.ts
The proxy removes every inbound x-ficta-* header before upstream forwarding, while profile-specific ticket and cache tests are removed or replaced.

Development build metadata

Layer / File(s) Summary
Git-derived gateway build ID
scripts/dev-env.mjs, apps/gateway/.env.example, apps/gateway/README.md
Unset development build IDs are derived from the short Git SHA and marked dirty when the working tree contains changes; deployment overrides remain documented.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Gateway
  participant FictaProxy
  participant ProtectionEngine
  participant Upstream
  Client->>Gateway: Send chat or protection-preview request
  Gateway->>FictaProxy: Forward scope and request data without detection profile
  FictaProxy->>ProtectionEngine: Begin request by scope key
  ProtectionEngine->>Upstream: Forward request after removing x-ficta-* headers
  Upstream-->>ProtectionEngine: Return response
  ProtectionEngine-->>Gateway: Return protected response or ticket result
  Gateway-->>Client: Return chat or preview response
Loading

Possibly related PRs

  • SerovaAI/ficta#50: Overlaps in Presidio sidecar bootstrap and verification code.
  • SerovaAI/ficta#70: Introduced the per-thread and per-request detection jurisdiction flow removed here.
  • SerovaAI/ficta#71: Added the jurisdiction UI and helpers removed from the chat components.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is related to the change theme, but it is too vague to describe the actual scope of the PR. Use a more specific title, such as removing detection-jurisdiction support or switching to country-scoped Presidio configuration.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

@coderabbitai coderabbitai 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.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.changeset/supported-countries-registry.md:
- Around line 10-12: Remove internal evaluation details from
.changeset/supported-countries-registry.md lines 10-12, including the
false-positive measurement and example, while retaining only the default
behavior and UK opt-in instructions. Also update
packages/ficta/presidio/default_recognizers.yaml lines 20-24 to remove “retained
for parity” and the unresolved “revisit” note, documenting only the effective
default behavior.

In `@packages/ficta/presidio/ficta_presidio/service.py`:
- Around line 29-34: Update the FICTA_PRESIDIO_SUPPORTED_COUNTRIES handling to
normalize requested ISO-3166-1 alpha-2 codes, validate every code against the
registry’s supported country codes, and raise before assigning
registry.recognizers when any are unknown. Preserve the existing filtering
behavior and ensure an explicitly empty list continues to select only
locale-agnostic recognizers.

In `@scripts/dev-env.mjs`:
- Around line 166-168: Update the status handling in the dev identifier logic to
return undefined when spawnSync for “git status --porcelain” reports a non-zero
exit status, before constructing the dev-${sha} value. Preserve the existing
dirty-tree suffix behavior only for successful status checks.

In `@scripts/dev-runner.mjs`:
- Around line 125-128: Update the existing analyzer reuse and health-check flow
in the dev runner, not only the container spawn arguments, so an explicitly
configured FICTA_PRESIDIO_SUPPORTED_COUNTRIES scope is verified against the
running sidecar’s loaded recognizers before reuse. If the scope cannot be
confirmed or does not match, reject the existing sidecar and continue with
fresh-container startup; preserve reuse only when the country scope is
validated.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 13cec79e-40e0-4cef-adec-98d446ba2da3

📥 Commits

Reviewing files that changed from the base of the PR and between a52aca1 and f2f65cc.

📒 Files selected for processing (47)
  • .changeset/supported-countries-registry.md
  • .changeset/thread-jurisdiction-detection.md
  • apps/gateway/.env.example
  • apps/gateway/README.md
  • apps/gateway/docs/threat-model-pii.md
  • apps/gateway/drizzle/0013_drop-detection-jurisdictions.sql
  • apps/gateway/drizzle/meta/0013_snapshot.json
  • apps/gateway/drizzle/meta/_journal.json
  • apps/gateway/src/components/chat/ChatView.tsx
  • apps/gateway/src/components/chat/JurisdictionSidebar.tsx
  • apps/gateway/src/components/chat/TopBar.tsx
  • apps/gateway/src/lib/detection-jurisdictions.ts
  • apps/gateway/src/lib/model-adapter.ts
  • apps/gateway/src/lib/protection-preview.ts
  • apps/gateway/src/lib/storage/drizzle/schema.ts
  • apps/gateway/src/lib/storage/drizzle/store.server.ts
  • apps/gateway/src/lib/storage/storage.server.ts
  • apps/gateway/src/lib/storage/threads.ts
  • apps/gateway/src/lib/storage/types.ts
  • apps/gateway/src/routes/api/chat.ts
  • apps/gateway/src/routes/api/protection-preview.ts
  • apps/gateway/src/routes/chat.$threadId.tsx
  • apps/gateway/test/detection-jurisdictions.test.ts
  • apps/gateway/test/storage.test.ts
  • docker-compose.sidecars.yml
  • packages/ficta/README.md
  • packages/ficta/docs/plugins.md
  • packages/ficta/presidio/Dockerfile
  • packages/ficta/presidio/default_recognizers.yaml
  • packages/ficta/presidio/ficta_presidio/service.py
  • packages/ficta/scripts/verify-presidio-sidecar.mts
  • packages/ficta/src/engine/engine.ts
  • packages/ficta/src/engine/plugins/pii/jurisdictions.ts
  • packages/ficta/src/engine/plugins/pii/presidio-recognizer.ts
  • packages/ficta/src/engine/plugins/types.ts
  • packages/ficta/src/engine/redaction-engine.ts
  • packages/ficta/src/server.ts
  • packages/ficta/test/dev-runner.test.ts
  • packages/ficta/test/jurisdictions.test.ts
  • packages/ficta/test/loopback-multiturn.test.ts
  • packages/ficta/test/presidio.test.ts
  • packages/ficta/test/protection-preview.test.ts
  • packages/ficta/test/scope.test.ts
  • packages/protocol/src/index.d.ts
  • packages/protocol/src/index.js
  • scripts/dev-env.mjs
  • scripts/dev-runner.mjs
💤 Files with no reviewable changes (21)
  • apps/gateway/src/lib/detection-jurisdictions.ts
  • apps/gateway/src/lib/protection-preview.ts
  • apps/gateway/test/detection-jurisdictions.test.ts
  • apps/gateway/src/lib/storage/types.ts
  • packages/ficta/src/engine/plugins/pii/jurisdictions.ts
  • packages/ficta/src/engine/plugins/types.ts
  • packages/protocol/src/index.js
  • apps/gateway/src/lib/storage/drizzle/schema.ts
  • apps/gateway/src/routes/chat.$threadId.tsx
  • .changeset/thread-jurisdiction-detection.md
  • apps/gateway/src/components/chat/JurisdictionSidebar.tsx
  • apps/gateway/src/lib/storage/storage.server.ts
  • packages/ficta/test/jurisdictions.test.ts
  • apps/gateway/src/lib/model-adapter.ts
  • apps/gateway/src/lib/storage/threads.ts
  • apps/gateway/src/routes/api/protection-preview.ts
  • apps/gateway/src/components/chat/TopBar.tsx
  • apps/gateway/test/storage.test.ts
  • packages/ficta/test/protection-preview.test.ts
  • packages/protocol/src/index.d.ts
  • packages/ficta/test/scope.test.ts

Comment on lines +10 to +12
locale-agnostic recognizers always load. Notably, the UK NHS recognizer no longer runs on default
traffic (it false-positives on ~10% of arbitrary 10-digit numbers, e.g. ZA phone and account
numbers) — add `uk` to the country scope for UK-matter deployments. `FICTA_PII_PRESIDIO_ENTITIES`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Keep internal evaluation and strategy out of published package content.

Both sites disclose internal rationale rather than only the supported public contract:

  • .changeset/supported-countries-registry.md#L10-L12: remove the false-positive measurement and example; retain only the default behavior and opt-in instructions.
  • packages/ficta/presidio/default_recognizers.yaml#L20-L24: remove “retained for parity” and the unresolved “revisit” note; document only the effective default.

As per coding guidelines, red-team findings, internal specifications, and unreleased strategy must remain in SerovaAI/ficta-internal.

📍 Affects 2 files
  • .changeset/supported-countries-registry.md#L10-L12 (this comment)
  • packages/ficta/presidio/default_recognizers.yaml#L20-L24
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.changeset/supported-countries-registry.md around lines 10 - 12, Remove
internal evaluation details from .changeset/supported-countries-registry.md
lines 10-12, including the false-positive measurement and example, while
retaining only the default behavior and UK opt-in instructions. Also update
packages/ficta/presidio/default_recognizers.yaml lines 20-24 to remove “retained
for parity” and the unresolved “revisit” note, documenting only the effective
default behavior.

Source: Coding guidelines

Comment thread packages/ficta/presidio/ficta_presidio/service.py
Comment thread scripts/dev-env.mjs
Comment thread scripts/dev-runner.mjs
@steflsd
steflsd merged commit b96f1b0 into main Jul 17, 2026
4 checks passed
@steflsd
steflsd deleted the feat/supported-countries-registry branch July 17, 2026 06:38
@github-actions github-actions Bot mentioned this pull request Jul 17, 2026
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