Skip to content

feat(frontend): the dataset seam in the BFF — slug guard, access scoping, erweb columns (datasets PR2) - #381

Merged
athvin merged 2 commits into
mainfrom
bm/datasets-p2-frontend-prep
Nov 2, 2026
Merged

athvin merged 2 commits into
mainfrom
bm/datasets-p2-frontend-prep

Conversation

@athvin

@athvin athvin commented Nov 2, 2026

Copy link
Copy Markdown
Owner

PR 2 of the datasets program — frontend prep, inert: nothing calls the new guard yet, and every new erweb column defaults to 'default', the name the backend sweep (PR3) gives each existing org's one dataset.

What

  • proxy.ts: DATASET_SLUG / requireDatasetSlug (the org traversal guard's twin — the dataset segment will be raw-interpolated into /v1/orgs/{org}/datasets/{ds}/… with the BFF's privileged credential attached), requireDatasetAccess (org membership + slug check; a dataset adds scoping, not a second permission system), datasetPath (the one audited place the dataset-scoped upstream path is built).
  • errors.ts: dataset_not_active joins the 409 family; conflictCode() splits writer-lock / dataset / org conflicts by detail text.
  • check-bff-authz.mjs: the orgs rule becomes ["requireOrgAccess", "requireDatasetAccess"] — landing this before any moved route is what keeps the gate from hard-failing mid-switchover.
  • erweb migration 0007: saved_views / segments / review_recommendations gain NOT NULL dataset (default 'default'); review_recommendations PK → (org, dataset, review_id) because review ids are lake-local; usage_events gains a nullable dataset (attribution only). drizzle-kit emitted the new PK constraint before the column it references — reordered by hand; the PGlite unit tier applies the file, so the order is exercised on every pnpm check.
  • adjudicate store: dataset threaded through the upsert target and batch read (callers pass "default" until the route move), with a test that a crm review never wears a default-dataset verdict.

Tests

New bff-dataset-access.test.ts (slug grammar incl. traversal shapes, denial-status matrix unchanged, datasetPath); bff-authz-gate.test.ts gains the dataset-route case; adjudicate-store.test.ts gains the cross-dataset isolation case. pnpm check green locally (lint, format, types, authz gate, unit+coverage).

🤖 Generated with Claude Code

bmoore813 and others added 2 commits November 2, 2026 09:01
…ing, erweb columns (datasets PR2)

Prep for the dataset-scoped routes, inert until they land: nothing calls
requireDatasetAccess yet and every new erweb column defaults to 'default',
the name the backend sweep will give each existing org's one dataset.

- proxy.ts: DATASET_SLUG + requireDatasetSlug (the org traversal guard's twin
  — the segment is raw-interpolated with the privileged credential attached),
  requireDatasetAccess (org membership + the slug check; a dataset adds
  scoping, not a second permission system), and datasetPath as the one audited
  place a dataset-scoped upstream path is built.
- errors.ts: dataset_not_active joins the 409 family; conflictCode() tells the
  three conflicts apart by detail text.
- check-bff-authz.mjs: the orgs rule accepts either guard, so a handler under
  datasets/[ds] satisfies the same invariant through requireDatasetAccess.
- erweb migration 0007: saved_views/segments/review_recommendations gain a
  NOT NULL dataset (default 'default'; review_recommendations' PK becomes
  (org, dataset, review_id) because review ids are lake-local), usage_events a
  nullable one (attribution only — billing stays org-level). drizzle-kit
  emitted the ADD CONSTRAINT before the ADD COLUMN it references; the
  statements are reordered by hand, and the PGlite unit tier applies the file
  so the order is now exercised on every run.
- adjudicate store threads the dataset through its upsert target and batch
  read, with a test proving a crm review never wears a default-dataset verdict.

Co-Authored-By: Claude Fable 5 <[email protected]>
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.

2 participants