Files
Piotr ChojnackiandClaude Fable 5.2 3943e8a716 Console: the cycle page no longer builds a handler from the address bar
viewCycleDetail took the id from the hash and, for an id it did not know,
drew a made-up open cycle with a Close button whose onclick carried that
id as '${esc(id)}'. esc() is no protection inside a quoted JS string in an
attribute: the HTML parser turns ' back into ' before the handler is
compiled. A link to #/cycles/<text> therefore ran that text as script on
one click, with the reader's session, on the platform's one origin.

- An unknown cycle is "Review cycle not found." (after one re-read of the
  list, so a cycle created since this tab loaded still opens), like a firm
  or a matter.
- The page uses the server's c.id from then on, also for the snapshots call.
- jsArg() (esc(JSON.stringify(v))) for every inline handler argument: the
  cycle's Close button and the two Edit buttons that used the same shape.
- test_frontend_xss_tripwires pins the helper, the absence of '${esc(' in a
  handler and of the fallback cycle. CLAUDE.md states the rule.

Checked without a browser: the console script parses, and the new asserts
hold against the file. pytest not run here (no dredd-core install).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-14 22:24:34 +01:00

30 KiB
Raw Permalink Blame History

CLAUDE.md

Guidance for Claude Code when working in this repository.

What this is

Counsel Scorecard — a self-hosted, single-tenant questionnaire & scoring engine. Configurable questions → answer options → weighted questionnaires → append-only responses-with-history; review cycles roll responses into immutable, explainable composite scores per law firm ("counsel"). Stack: FastAPI + SQLAlchemy 2 + Alembic + PostgreSQL 16 on the shared dredd-core package (identity/session/auth/audit + the ORM Base), Argon2id auth, RBAC, append-only audit, opt-in OpenTelemetry, a static admin console, and CI (Postgres tests + license gate). License: Apache-2.0.

A module of the platform. The Dredd family — Atrium the hub, plus Galena, Sygna and Counsel Scorecard — is one platform, one account, one admin pane. It runs at one origin, one module per path (/atrium, /galena, /sygna, /counsel), with / redirecting to /atrium. A person has ONE identity: they sign in once, in Atrium, and every module resolves the same session. Modules keep their own schema and their own least-privilege roles — database isolation is unchanged — but identity is shared, not duplicated. What a module still owns alone is its domain: here that is firms, matters, questions, questionnaires, responses, review cycles and scoring, plus Counsel's own RBAC role on counsel_user_profile. Because there is one origin there is no cross-origin handoff to design: no signed assertion, no audience binding, no SameSite dance. A design that invents a token handoff for this topology is over-engineering.

Four admin@example.com rows — one per app — are a defect, not a design. Any text saying "no cross-app SSO", "separate logins", or that Atrium "links but never signs you in" is stale: correct it. That model was inferred by an assistant, never chosen.

This module is counsel, never scorecard. The slug is already the identity everywhere that matters — schema counsel, roles counsel_app/counsel_migrator, cookie counsel_session, compose services, --expect-schema counsel, and the /counsel path. Only the retired public hostname ever said scorecard; don't reintroduce it.

Where the platform is today: one origin, four paths, and one account. With IDENTITY_SCHEMA=dredd this app has no accounts of its own: app_user, session and module_permission live in a neutral schema the hub owns and every module reads, so signing in once at /atrium signs you in here — same origin, same cookie, same session row, no handoff. Being signed in is not being let in: no module_permission row naming counsel means no entry, and that is decided once, in deps.get_current_user. Standalone at the origin root stays supported and is the default (ROOT_PATH and IDENTITY_SCHEMA empty, this repo's own docker-compose.yml, uvicorn published on :8081 with no proxy), and platform mode must never become a code fork of it: every default reproduces the standalone behaviour, and settings.shares_identity is the one predicate anything branches on.

See README.md for the full feature/architecture tour and CREDITS.md for dependencies and design inspirations.

Where things live

backend/app/
  main.py config.py db.py deps.py errors.py security.py observability.py
  enums.py schemas.py seed.py logging_config.py
  models/    ORM entities      services/  auth, moderation, responses, scoring, search, audit
  routers/   HTTP + RBAC (auth, users, firms, matters, questions, questionnaires,
             responses, review_cycles, search, dictionaries, health + GET /config)
backend/alembic/   env + 0001 (create_enum_types + create_all: dredd-core core + CS domain models)
                   + 0002_runtime_grants (dredd-core runtime_grants_sql for DB_APP_ROLE)
                   + 0003_user_role_admin_removed (native enum swap: `admin` leaves `user_role`)
                   + 0004_shared_identity (the cutover; a no-op unless IDENTITY_SCHEMA is set)
                   + 0005_module_permission (module_moderator -> module_permission + role, for a
                     database whose 0001 ran under a v0.10.x core; the MIRROR of 0004 — a no-op
                     when IDENTITY_SCHEMA *is* set, since the table is then the hub's)
backend/tests/     unit (DB-free) + integration (Postgres)
backend/scripts/license_gate.py
frontend/index.html   the entire admin console (one static file, no build)
scripts/build_demo.py   builds the live demo (index.html + seeded mock API + OG/Twitter
             social-preview <head> meta with absolute $URL paths; copies brand assets; served via Netlify)
gallery/   screenshots (referenced by SHOWCASE.md)
assets/    app icon — icon.svg + icon.png + og.png (1200×630 social card; Tabler square + percentage, Open Color orange)
db/init/   extensions + least-privilege roles (run as superuser)
db/managed/    the family's shared managed PostgreSQL: provision.sql (rendered by dredd-core) + README runbook
observability/   otel-collector-config.yaml
docker-compose.yml  docker-compose.managed-db.yml (override: no local postgres)  .env.example

Strict one-way layering — routers/ (HTTP, validation, RBAC; never touches the DB session) → services/ (domain logic; never builds raw SQL) → models/ (ORM). Keep it.

Project docs live in the sibling ../Counsel-Scorecard/ folder (hyphenated), NOT in this repo. Review reports, the UX spec, and remediation tracking go there (e.g. code-rereview-2026-06-11.md, open-mercato-like_ux_spec.md, REALIZATION-REPORT.md). Code-repo docs that DO live here: README.md, CREDITS.md, CLAUDE.md, SHOWCASE.md, LICENSE, NOTICE, and the deployment runbook db/managed/README.md.

Commands

DREDD_CORE_TOKEN=... docker compose up -d --build   # full stack: postgres → migrate(+seed) → backend on :8081;
                                    # the token is a BuildKit build secret: shell only, never .env
cd backend && pytest                # DB-free unit tests; DB-backed ones auto-skip w/o DATABASE_URL,
                                    # and tests/test_platform_live.py also needs IDENTITY_SCHEMA
alembic upgrade head --sql          # inspect generated DDL without a DB
python scripts/license_gate.py      # the CI license gate locally

CI (.github/workflows/ci.yml): runs the full suite against real Postgres 16 and 17 as the DML-only app role (standalone: 162 passed / 10 skipped), reports coverage (not gated), runs the managed-db job — the family's shared managed database emulated on Postgres 17, first as a standalone Counsel and then as a platform: a stand-in hub owns dredd, Counsel is re-provisioned as a reader, its cutover runs, and tests/test_platform_live.py proves a hub-issued session signs you in here and measures the grants as the runtime role — and runs the license gate.

Security invariants — preserve these

Backend:

  • Append-only audit: the runtime app DB role has no UPDATE/DELETE on audit_log; DDL is isolated to the migrator role. Never grant the app role DDL or audit mutation.
  • Least privilege: app = DML only, migrator = DDL. Postgres uses expose, never ports — the backend is the only host-published service.
  • pg8000 paramstyle is %s (pyformat). Literal % in SQL must be escaped as %%. This bit us before — check any hand-written SQL string.
  • Built on dredd-core (private package, pinned by tag in requirements.txt): the shared identity/session/auth/audit tables + the SQLAlchemy Base are imported from dredd_core, not defined here. The migration is create_enum_types() + Base.metadata.create_all() (dredd-core ships models, not migrations — the app owns its history). Never edit dredd-core from this repo: change it there, bump a tag, and repin. CS keeps its own domain RBAC (UserRole on counsel_user_profile + matter-ownership); it does not use the core node/authz tree — those tables (node/permission_grant/favorite) still get created by create_all because they ride on the shared Base, but CS never queries them (the firm→workspace mapping that would is a deferred question). Filtering them out would fight adopting the shared Base wholesale, so we don't.
  • Managed Postgres = the family's shared managed database (db/managed/README.md; one database at a managed provider for Atrium, Galena, Sygna and Counsel; the same steps fit any Postgres 16/17 reached over a network). No provider is named anywhere — code, config, CI, docs; the know-how stays generic ("some poolers want <role>.<tenant> user names", "download the provider's root CA from its dashboard", "keep the schema out of any auto-generated API", "a restore may drop custom role passwords"). Preserve all of these:
    • Own schema, never public: Counsel lives in schema counsel, owned by its migrator. Nothing is schema-qualified in code: the roles' search_path = counsel, extensions (set by provisioning) places tables, enum types and alembic_version, and pg_trgm resolves from extensions. On the platform that becomes counsel, dredd, extensions — Counsel's own schema first, always, or alembic_version and every new table would land in a schema its migrator does not own. The cost of that correct order is the shadow table the lifespan assertion exists to catch.
    • The shared identity schema is PROVISIONING, not a migration. db/managed/provision.sql is rendered with --identity-schema dredd --identity-owner atrium_migrator; it grants this app's two roles USAGE and sets their search_path. The tables in it and the tier grants belong to the OWNER's migration (Atrium's), because a GRANT by anyone else is a warning rather than an error — which is why 0004 deliberately grants nothing.
    • Per-app roles via DB_APP_ROLE: role names are cluster-wide there, so the roles are counsel_migrator / counsel_app; the runtime role's name is config (DB_APP_ROLE, default app locally and in CI) and 0002_runtime_grants grants to it. Never create plain app/migrator roles in the shared project.
    • Never migrate as postgres (or any superuser), and 0001's FIRST statement is what says so: dredd-core's migration_preflight_sql refuses by name before anything is created — keep it first. runtime_grants_sql repeats the check in 0002, but 0002 is reached only if 0001 succeeded, so as the platform admin Counsel built every table first and only Alembic's one transaction took them away again. Sygna, whose 0001 leaves the identity tables to the hub, did not even get that far: it died on relation "app_user" does not exist, the platform admin's search_path never carrying dredd — refused by accident, naming neither the problem nor the fix. The whole upgrade rolls back either way. Local dev migrates as migrator too.
    • Grants fail loudly: a missing runtime role, or a grant/revoke that did not take, raises instead of warning. A new revision that adds tables must end with op.execute(runtime_grants_sql(...)) with the same arguments as 0002 (the shared project sets no default privileges).
    • TLS only through make_engine: every engine (db.py, alembic/env.py, the seed, scripts/create_extensions.py, the test fixture) is dredd_core.db.make_engine — never create_engine/engine_from_config (a DB-free test enforces it) — so ?sslmode=verify-full&sslrootcert= works and prefer/allow/disable are refused. env.py never passes the URL through config.set_main_option (configparser %-interpolation breaks URL-encoded passwords); offline it uses strip_tls_params.
    • Settings refuse unsafe database URLs at start-up (config._database_urls_are_safe, before anything connects): the DATABASE_URL user minus .<tenant> must equal DB_APP_ROLE and differ from the MIGRATION_DATABASE_URL user, and the family's one TLS rule (dredd_core.db.require_verified_tls) holds: a host that is not local ("", localhost, 127.0.0.1, ::1, postgres, or an entry of DB_LOCAL_HOSTS) needs sslmode=verify-full (with sslrootcert, or the system trust store). DB_ALLOW_UNVERIFIED_TLS is the single documented escape hatch — add no other opt-out. The refusal names neither the host nor the password (hide_input_in_errors; an unencoded @ in a password makes part of it the parsed host).
    • Pooler in session mode (never transaction mode), users <role>.<tenant> where the pooler wants the tenant in the user name. Four apps share one connection limit: the runtime pool is DB_POOL_SIZE/DB_MAX_OVERFLOW; migrate and seed use NullPool. The backend never gets migrator credentials (docker-compose.managed-db.yml).
    • Provisioning is dredd-core's, not ours: db/managed/provision.sql is rendered by python -m dredd_core.managed provision --sql-only ... --output; never hand-edit it (CI's --check-file and a DB-free test fail when it is stale).
    • PG 16 + 17: CI runs the suite on both, plus the managed-db job (emulate → provision → migrate → tests as counsel_app → managed check with isolation) on 17.
  • One platform, one account — and this module is a READER of identity, never a writer. With IDENTITY_SCHEMA set, app_user / session / module_permission live in the shared schema the hub owns. counsel_app holds SELECT on seven columns of app_user (never password_hash, failed_login_count or locked_until), SELECT plus UPDATE (last_seen_at, expires_at, revoked_at) on session, SELECT on module_permission, and nothing else in that schema. Three things follow, and each is refused at the edge so a missing grant never surfaces as a 500 on an ordinary screen (services/auth.POLICY, from AuthPolicy.identity_writes_enabled / local_login_enabled / app_tokens_enabled):
    • nobody signs in here. POST /auth/login answers 404 naming the hub (the family's one answer, as Galena and Sygna give it); the console shows a Sign in at the hub button (GET /config → shares_identity), and a signed-in person refused by assert_may_use (403 on /auth/me) gets the no access card instead (showRefused), never the sign-in loop. IDENTITY_SCHEMA and SESSION_COOKIE_NAME=dredd_session are set together or not at all — Settings refuses either half alone. There is deliberately no break-glass: writing a session row needs an INSERT this app does not hold, because a role that can write one can mint a credential for the administrator. Do not "restore" a local login.
    • accounts are the hub's. Create/rename/deactivate all 409; Counsel keeps only the role on counsel_user_profile. seed.py skips the bootstrap account in this mode (it is the one legitimate is_admin write in the repo, and it is standalone-only).
    • app tokens: list and revoke here, mint in the hub (POST /api/v1/me/modules/counsel/tokens, still counsel_pat_).
  • No row means no entry, and that is the point of module_permission. One row per person per module in the shared schema, with a role — so there are four answers and the first is the absence of a row: no row = no access to Counsel at all; user = may use it; moderator = may use and administer it; app_user.is_admin = ADMINISTRATOR, platform-wide, everything everywhere, no row needed. Enforced once, in deps.get_current_user (moderation.assert_may_use, right after the token-scope check) — every authenticated route depends on it, so no route can forget it and the three require_* helpers need no change: require_role is a pure domain-role check and takes no db precisely because admission was settled at the edge. Before this, a stranger with a platform account could open every screen here and merely see nothing, which is not an access decision. Standalone it refuses nobody — core answers user for everybody where there is no platform, and emits no SQL — which is what lets one guard serve both shapes. Granting is Atrium's, always: this app holds SELECT on that table and no INSERT, so it can neither admit anyone nor promote anyone, itself least of all.
  • Two tiers, two words, used verbatim: ADMINISTRATOR is platform-wide (app_user.is_admin), MODERATOR is one module (a role = 'moderator' row in module_permission naming counsel). Both are granted in Atrium; this app reads them through services/moderation.py and deps.require_moderator / require_moderator_or_role. This module defines no require_administrator and must not — a module route guarded by the platform-wide tier would be a module deciding who runs the platform. Counsel has no node tree, so the projection is flat: a moderator of counsel holds every power UserRole.admin used to hold. It does NOT lift separation of duties — submitting an evaluation still needs matter_owner. Counsel also has no authz.bind_moderation call, and must not grow one: there is no role ladder and no tree here for the tier to project onto.
  • MODULE_SLUG is counsel, and it is the one name the hub has to spell the same way. The catalogue entry, POST /admin/modules/<slug>/moderators, POST /me/modules/<slug>/tokens and the <slug>_pat_ stamp are all keyed by it, in Atrium's repository, by hand. A mismatch is silent: this module only ever SELECTs module_permission WHERE module_slug = its own name, so a grant written against another spelling does not error, it simply never matches — the administrator sees the delegation succeed and the person is now refused at the door. (It happened: the catalogue said counsel-scorecard while this app answered to counsel, so moderator grants and hub-minted tokens both went nowhere.) It is the same word as the schema, both role names, the URL path and the cookie — never scorecard, never the hyphenated display name, which belongs to the Python package and OTEL_SERVICE_NAME and nowhere else. .env.example sets it explicitly rather than leaning on the default, and two DB-free tests pin it, including every me/modules/<slug>/tokens written into a comment, a docstring or the docs — those are the instructions an operator follows, so prose goes stale in exactly the same silence as SQL.
  • UserRole has no admin and must never get one back (0003 swapped the native enum and mapped those rows to legal_ops). It was the one place in the family where a module wrote a platform-wide fact: routers/users.py kept app_user.is_admin in step with it, so a Counsel admin became an Atrium, Galena and Sygna administrator. No assignment to is_admin may exist under app/routers/ — a DB-free test asserts it. _assert_not_last_admin is gone with it: that guard counted platform administrators from inside a module, and the rule is the hub's now.
  • The lifespan asserts the identity tables resolve in the shared schema, on every start (dredd_core.identity_schema.assert_identity_schema). Never make it optional: with search_path = counsel, dredd, extensions an unqualified app_user resolves to a LOCAL copy if one exists and everything keeps working — silently back to two rows per person, which is the exact defect this change removes. A restored dump or a stray create_all is all it takes.
  • 0001 is the one revision that names every table unqualified, and on the platform an unqualified name can mean the HUB's table. Both halves of this were measured against a live two-schema database, and both were silent — so keep both fixes. create_all(conn, checkfirst=False): SQLAlchemy's existence check follows the whole search_path, so it answers "app_user exists" about dredd.app_user and quietly skips building this app's own, giving a fresh install a different shape from a migrated one. And a downgrade that drops only what current_schema() actually holds: once 0004 has merged this schema's accounts away, an unqualified DROP TABLE app_user resolves to dredd.app_user and alembic downgrade base reaches for the platform's entire identity store. Live, that was refused only by PostgreSQL's ownership rule — luck standing in for a decision. 0004's own refusal to downgrade closes the ordinary route but not a downgrade run with IDENTITY_SCHEMA merely unset, which is why the guard is on the database rather than on a setting. Any future revision naming a bare identity table inherits the same hazard.
  • Never change what 0001 creates without a follow-up revision for databases migrated before. 0001 builds from Base.metadata, so a core bump silently changes what a fresh database gets and reaches no existing one — 0001 is stamped and never runs again. Renaming module_moderator to module_permission in dredd-core v0.11.0 is exactly that, and 0005 is the follow-up: a catalog check in the app's own schema, then rename-or-create, idempotent. The symptoms of skipping it all arrive far from the cause (a query for a relation that does not exist, on an ordinary screen), which is why this is a rule and not a judgement call.
  • Argon2id hashing + app-level login lockout (LOGIN_MAX_ATTEMPTS/LOGIN_LOCKOUT_MINUTES).
  • Server-side sessions (session table) so logout/deactivate is an instant kill-switch.
  • The session cookie is Path=/, HttpOnly, SameSite=Lax, Secure auto-detected from the request scheme (routers/auth), with no Domain. Every part of that is load-bearing: Path=/api is never sent back behind the platform's handle_path /counsel/*, so sign-in silently never sticks; Strict withholds the cookie on inbound links while buying nothing the cross-site guard below does not already do; keying Secure off APP_ENV drops the cookie on a plain-HTTP deployment running APP_ENV=production, which is the platform today. set_cookie and delete_cookie must always name the same path, or sign-out clears nothing. Its NAME is SESSION_COOKIE_NAME (counsel_session; dredd_session on the platform, where all four modules read one cookie — that, plus one origin, IS the single sign-on). deps.LEGACY_SESSION_COOKIES keeps reading the old name for one more request, and routers/auth expires it on the next sign-out, so the rename costs nobody their session.
  • Cookie-authenticated writes must be same-origin — deps.refuse_cross_site_write, registered once as an app-wide dependency in main.py (the decision is core's, dredd_core.cross_site.cross_site_write_refused since v0.14.0; the dependency only raises this app's own error), checks Sec-Fetch-Site and, where browsers omit it (plain HTTP, older Safari), Origin against Host; a bearer token and CORS_ALLOW_ORIGINS entries are trusted. Never add per-route calls or exempt a route (login/logout included). Its property changed under one origin: /galena is same-origin with /counsel, so this guard no longer separates one module from another — an XSS in any console can drive all four APIs. It still blocks genuinely foreign sites, so it stays; don't "restore" it as a module boundary. Two rules follow: never list a family host in CORS_ALLOW_ORIGINS (a listed origin is trusted outright, bypassing both signals), and never let the proxy rewrite Host per module.
  • Errors are RFC 9457 Problem Details; stack traces are hidden when APP_ENV=production; DB DataError maps to 422 (not 500).
  • Emails are validated by an in-app regex (schemas.Email, a pydantic AfterValidator) — no email-validator dependency.
  • matter_owner can only act on matters they own (matter_scope_filter in deps.py, which now takes db: the administration half of the answer can be a lookup rather than a column). Whoever administers Counsel, legal_ops and viewer cannot submit evaluations by design — separation of duties, and the tier deliberately does not lift it.
  • FORWARDED_ALLOW_IPS is scoped to the trusted proxy (never *) so the real client IP lands in the audit INET columns: empty standalone (the image defaults it to loopback; nothing sits in front), Counsel's network on the platform (Atrium's compose). deps.client_ip reads request.client, which uvicorn's --proxy-headers resolved from a trusted hop only.
  • No reverse proxy, anywhere. The backend is its own edge (app/edge.py, wired in main.py): it serves the console (frontend/, /frontend in the image) at / LAST, behind ConsoleUnlessApi, so /api/* and /healthz never fall to it (unknown → 404 problem, wrong method → 405 + Allow); any other GET for a missing file gets index.html (the SPA fallback). SecurityHeaders (outermost middleware) stamps every response, errors included: nosniff, Referrer-Policy: same-origin (the family's value), the CSP (frame-ancestors from FRAME_ANCESTORS, 'none' → XFO DENY or 'self' → SAMEORIGIN, anything else refuses start-up), HSTS only when the scheme is https; uvicorn runs --no-server-header. Also gzip (min 1000 B) and a 100 MB request-body cap (BodySizeLimit, 413). /healthz is an empty DB-free 200. Every path comparison there reads get_route_path(scope), never request.url.path (ROOT_PATH). uvicorn's flags live ONLY in backend/Dockerfile's CMD — no compose command: override.

Frontend (frontend/index.html) — keep all of these when editing:

  • esc() HTML-escapes every dynamic value interpolated into markup. Use it everywhere.
  • jsArg() for a value passed as an argument of an inline handler (onclick="fn(${jsArg(v)})"), never '${esc(v)}': the HTML parser turns &#39; back into ' before the handler is compiled, so esc() inside a quoted JS string protects nothing. And a page is built from the record the server returned, never from the id in the address bar: an unknown id is "not found". test_frontend_xss_tripwires pins both.
  • The bearer token is kept in memory only (state.token) — never localStorage/sessionStorage.
  • sanitizeBase() restricts the API base (read from localStorage.cs_base2) to a same-origin path, the same origin, or localhost — so a poisoned base can't exfiltrate the token. One leading slash only: //host and /\host are another origin. Its default is derived from the document (new URL('api/v1', document.baseURI).pathname), never a root-absolute literal, so the console calls /counsel/api/v1 when served at /counsel/ and /api/v1 at the origin root. The key is cs_base2 because all four consoles now share one origin, and therefore one localStorage.
  • fetch uses credentials:'include' + Authorization: Bearer; cross-origin needs the origin in CORS_ALLOW_ORIGINS.
  • Enum values come from /enums with ENUM_FALLBACKS if the call fails.

Frontend design system

One static file, no framework/build. Hash-routed admin SPA: grouped sidebar nav (OVERVIEW / DIRECTORY / QUESTIONNAIRES / EVALUATIONS / REVIEW / ADMIN / HELP) → data tables with row menus → full-page create forms + edit modals; dashboard widgets; cycle-detail rankings; command palette (Ctrl/⌘K) backed by the /search FTS endpoint; toast; request-log slideover. The HELP group holds an About page (#/about, viewAbout) — plain-language intro + Apache-2.0 license summary, fully localized like the rest (every string has an I18N.pl entry).

  • Palette: Open Color (https://yeun.github.io/open-color, MIT), light + dark via [data-theme]. gray ramp for neutrals — primary #212529 (→ #dee2e6 in dark); indigo accent #4263eb; green/yellow/red/pink status. Brand mark is the app icon (assets/icon.svg, inlined in the topbar + login). Every hex in the file is an Open Color value.
  • Tokens: --radius ~10px (controls ~8px), sidebar 240px / collapsed rail 72px, topbar ~60px, 4px foreground active bar on the current nav item (no border).
  • Responsive: the topbar breadcrumb and workspace chip (.org) never wrap — fitOrg() hides the chip when the bar is too narrow to show it fully (reveal-then-measure-next-task, since reading a child's box in the same task it leaves display:none is unreliable). Below 880px the sidebar becomes an off-canvas drawer (scrim + auto-close on navigation), the topbar sheds its chip/breadcrumb/email, and wide data tables scroll horizontally (.dt-scroll).
  • Theme: pre-paint script in <head> avoids flash; cycleTheme() is system→light→dark; toggles on both the login screen and the topbar; choice persists in localStorage.cs_theme.
  • Icons: Tabler Icons (@tabler/icons, MIT) — 24×24 outline path data embedded inline, rendered stroke:currentColor (2px) by svg(); no icon library/package bundled.
  • Localization (EN/PL): dependency-free (native Intl + a Polish dictionary I18N.pl). A MutationObserver localizes every render by matching the exact English text; each node's pristine English is remembered (WeakMap) so toggling back to EN is lossless. Language auto-detects from navigator.language (Polish → pl, else en), persists in localStorage.cs_lang; an EN/PL toggle sits left of the theme toggle on both topbar and login. esc() still applies — translations set textContent/nodeValue, never HTML. Data (firm/matter names) is never a key, so it's untouched. The sidebar nav search filters on both the English label and its localized form (_tr(it.label)), so it works in either language.

This UX is inspired by Open Mercato, not a copy — small deviations from it are intentional and fine. Don't chase pixel-parity with Open Mercato. Full audit + token reference: ../Counsel-Scorecard/open-mercato-like_ux_spec.md.

Status

Re-review remediation (June 2026) on branch rereview-remediation-2026-06-11 resolved all 28 findings (H1, M1–M6, I1–I4, L1–L17). Report: ../Counsel-Scorecard/code-rereview-2026-06-11.md.