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>
30 KiB
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
appDB role has noUPDATE/DELETEonaudit_log; DDL is isolated to themigratorrole. Never grant the app role DDL or audit mutation. - Least privilege:
app= DML only,migrator= DDL. Postgres usesexpose, neverports— 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 inrequirements.txt): the shared identity/session/auth/audit tables + the SQLAlchemyBaseare imported fromdredd_core, not defined here. The migration iscreate_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 (UserRoleoncounsel_user_profile+ matter-ownership); it does not use the core node/authz tree — those tables (node/permission_grant/favorite) still get created bycreate_allbecause they ride on the sharedBase, but CS never queries them (thefirm→workspace mapping that would is a deferred question). Filtering them out would fight adopting the sharedBasewholesale, 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 schemacounsel, owned by its migrator. Nothing is schema-qualified in code: the roles'search_path = counsel, extensions(set by provisioning) places tables, enum types andalembic_version, and pg_trgm resolves fromextensions. On the platform that becomescounsel, dredd, extensions— Counsel's own schema first, always, oralembic_versionand 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.sqlis rendered with--identity-schema dredd --identity-owner atrium_migrator; it grants this app's two rolesUSAGEand sets theirsearch_path. The tables in it and the tier grants belong to the OWNER's migration (Atrium's), because aGRANTby anyone else is a warning rather than an error — which is why0004deliberately grants nothing. - Per-app roles via
DB_APP_ROLE: role names are cluster-wide there, so the roles arecounsel_migrator/counsel_app; the runtime role's name is config (DB_APP_ROLE, defaultapplocally and in CI) and0002_runtime_grantsgrants to it. Never create plainapp/migratorroles in the shared project. - Never migrate as
postgres(or any superuser), and0001's FIRST statement is what says so: dredd-core'smigration_preflight_sqlrefuses by name before anything is created — keep it first.runtime_grants_sqlrepeats the check in0002, but0002is reached only if0001succeeded, so as the platform admin Counsel built every table first and only Alembic's one transaction took them away again. Sygna, whose0001leaves the identity tables to the hub, did not even get that far: it died onrelation "app_user" does not exist, the platform admin's search_path never carryingdredd— refused by accident, naming neither the problem nor the fix. The whole upgrade rolls back either way. Local dev migrates asmigratortoo. - 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 as0002(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) isdredd_core.db.make_engine— nevercreate_engine/engine_from_config(a DB-free test enforces it) — so?sslmode=verify-full&sslrootcert=works andprefer/allow/disableare refused.env.pynever passes the URL throughconfig.set_main_option(configparser%-interpolation breaks URL-encoded passwords); offline it usesstrip_tls_params. - Settings refuse unsafe database URLs at start-up (
config._database_urls_are_safe, before anything connects): theDATABASE_URLuser minus.<tenant>must equalDB_APP_ROLEand differ from theMIGRATION_DATABASE_URLuser, 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 ofDB_LOCAL_HOSTS) needssslmode=verify-full(withsslrootcert, or the system trust store).DB_ALLOW_UNVERIFIED_TLSis 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 isDB_POOL_SIZE/DB_MAX_OVERFLOW; migrate and seed useNullPool. The backend never gets migrator credentials (docker-compose.managed-db.yml). - Provisioning is dredd-core's, not ours:
db/managed/provision.sqlis rendered bypython -m dredd_core.managed provision --sql-only ... --output; never hand-edit it (CI's--check-fileand a DB-free test fail when it is stale). - PG 16 + 17: CI runs the suite on both, plus the
managed-dbjob (emulate → provision → migrate → tests ascounsel_app→managed checkwith isolation) on 17.
- Own schema, never
- One platform, one account — and this module is a READER of identity, never a writer. With
IDENTITY_SCHEMAset,app_user/session/module_permissionlive in the shared schema the hub owns.counsel_appholdsSELECTon seven columns ofapp_user(neverpassword_hash,failed_login_countorlocked_until),SELECTplusUPDATE (last_seen_at, expires_at, revoked_at)onsession,SELECTonmodule_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, fromAuthPolicy.identity_writes_enabled/local_login_enabled/app_tokens_enabled):- nobody signs in here.
POST /auth/loginanswers 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 byassert_may_use(403 on/auth/me) gets the no access card instead (showRefused), never the sign-in loop.IDENTITY_SCHEMAandSESSION_COOKIE_NAME=dredd_sessionare set together or not at all —Settingsrefuses either half alone. There is deliberately no break-glass: writing asessionrow needs anINSERTthis 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.pyskips the bootstrap account in this mode (it is the one legitimateis_adminwrite 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, stillcounsel_pat_).
- nobody signs in here.
- No row means no entry, and that is the point of
module_permission. One row per person per module in the shared schema, with arole— 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, indeps.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 threerequire_*helpers need no change:require_roleis a pure domain-role check and takes nodbprecisely 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 answersuserfor 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 holdsSELECTon that table and noINSERT, 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 (arole = 'moderator'row inmodule_permissionnamingcounsel). Both are granted in Atrium; this app reads them throughservices/moderation.pyanddeps.require_moderator/require_moderator_or_role. This module defines norequire_administratorand 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 ofcounselholds every powerUserRole.adminused to hold. It does NOT lift separation of duties — submitting an evaluation still needsmatter_owner. Counsel also has noauthz.bind_moderationcall, and must not grow one: there is no role ladder and no tree here for the tier to project onto. MODULE_SLUGiscounsel, 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>/tokensand the<slug>_pat_stamp are all keyed by it, in Atrium's repository, by hand. A mismatch is silent: this module only everSELECTsmodule_permissionWHEREmodule_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 saidcounsel-scorecardwhile this app answered tocounsel, 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 — neverscorecard, never the hyphenated display name, which belongs to the Python package andOTEL_SERVICE_NAMEand nowhere else..env.examplesets it explicitly rather than leaning on the default, and two DB-free tests pin it, including everyme/modules/<slug>/tokenswritten 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.UserRolehas noadminand must never get one back (0003 swapped the native enum and mapped those rows tolegal_ops). It was the one place in the family where a module wrote a platform-wide fact:routers/users.pykeptapp_user.is_adminin step with it, so a Counsel admin became an Atrium, Galena and Sygna administrator. No assignment tois_adminmay exist underapp/routers/— a DB-free test asserts it._assert_not_last_adminis 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: withsearch_path = counsel, dredd, extensionsan unqualifiedapp_userresolves 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 straycreate_allis all it takes. 0001is 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 wholesearch_path, so it answers "app_userexists" aboutdredd.app_userand quietly skips building this app's own, giving a fresh install a different shape from a migrated one. And adowngradethat drops only whatcurrent_schema()actually holds: once0004has merged this schema's accounts away, an unqualifiedDROP TABLE app_userresolves todredd.app_userandalembic downgrade basereaches 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 withIDENTITY_SCHEMAmerely 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
0001creates without a follow-up revision for databases migrated before.0001builds fromBase.metadata, so a core bump silently changes what a fresh database gets and reaches no existing one —0001is stamped and never runs again. Renamingmodule_moderatortomodule_permissionin dredd-core v0.11.0 is exactly that, and0005is 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 (
sessiontable) so logout/deactivate is an instant kill-switch. - The session cookie is
Path=/,HttpOnly,SameSite=Lax,Secureauto-detected from the request scheme (routers/auth), with noDomain. Every part of that is load-bearing:Path=/apiis never sent back behind the platform'shandle_path /counsel/*, so sign-in silently never sticks;Strictwithholds the cookie on inbound links while buying nothing the cross-site guard below does not already do; keyingSecureoffAPP_ENVdrops the cookie on a plain-HTTP deployment runningAPP_ENV=production, which is the platform today.set_cookieanddelete_cookiemust always name the same path, or sign-out clears nothing. Its NAME isSESSION_COOKIE_NAME(counsel_session;dredd_sessionon the platform, where all four modules read one cookie — that, plus one origin, IS the single sign-on).deps.LEGACY_SESSION_COOKIESkeeps reading the old name for one more request, androuters/authexpires 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 inmain.py(the decision is core's,dredd_core.cross_site.cross_site_write_refusedsince v0.14.0; the dependency only raises this app's own error), checksSec-Fetch-Siteand, where browsers omit it (plain HTTP, older Safari),OriginagainstHost; a bearer token andCORS_ALLOW_ORIGINSentries are trusted. Never add per-route calls or exempt a route (login/logout included). Its property changed under one origin:/galenais 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 inCORS_ALLOW_ORIGINS(a listed origin is trusted outright, bypassing both signals), and never let the proxy rewriteHostper module. - Errors are RFC 9457 Problem Details; stack traces are hidden when
APP_ENV=production; DBDataErrormaps to 422 (not 500). - Emails are validated by an in-app regex (
schemas.Email, a pydanticAfterValidator) — noemail-validatordependency. matter_ownercan only act on matters they own (matter_scope_filterindeps.py, which now takesdb: the administration half of the answer can be a lookup rather than a column). Whoever administers Counsel,legal_opsandviewercannot submit evaluations by design — separation of duties, and the tier deliberately does not lift it.FORWARDED_ALLOW_IPSis scoped to the trusted proxy (never*) so the real client IP lands in the auditINETcolumns: empty standalone (the image defaults it to loopback; nothing sits in front), Counsel's network on the platform (Atrium's compose).deps.client_ipreadsrequest.client, which uvicorn's--proxy-headersresolved from a trusted hop only.- No reverse proxy, anywhere. The backend is its own edge (
app/edge.py, wired inmain.py): it serves the console (frontend/,/frontendin the image) at/LAST, behindConsoleUnlessApi, so/api/*and/healthznever fall to it (unknown → 404 problem, wrong method → 405 +Allow); any other GET for a missing file getsindex.html(the SPA fallback).SecurityHeaders(outermost middleware) stamps every response, errors included: nosniff,Referrer-Policy: same-origin(the family's value), the CSP (frame-ancestorsfromFRAME_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)./healthzis an empty DB-free 200. Every path comparison there readsget_route_path(scope), neverrequest.url.path(ROOT_PATH). uvicorn's flags live ONLY inbackend/Dockerfile's CMD — no composecommand: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'back into'before the handler is compiled, soesc()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_tripwirespins both.- The bearer token is kept in memory only (
state.token) — never localStorage/sessionStorage. sanitizeBase()restricts the API base (read fromlocalStorage.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://hostand/\hostare 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/v1when served at/counsel/and/api/v1at the origin root. The key iscs_base2because all four consoles now share one origin, and therefore onelocalStorage.fetchusescredentials:'include'+Authorization: Bearer; cross-origin needs the origin inCORS_ALLOW_ORIGINS.- Enum values come from
/enumswithENUM_FALLBACKSif 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].grayramp for neutrals — primary#212529(→#dee2e6in dark);indigoaccent#4263eb;green/yellow/red/pinkstatus. 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 leavesdisplay:noneis 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 inlocalStorage.cs_theme. - Icons: Tabler Icons (
@tabler/icons, MIT) — 24×24 outline path data embedded inline, renderedstroke:currentColor(2px) bysvg(); no icon library/package bundled. - Localization (EN/PL): dependency-free (native
Intl+ a Polish dictionaryI18N.pl). AMutationObserverlocalizes 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 fromnavigator.language(Polish →pl, elseen), persists inlocalStorage.cs_lang; an EN/PL toggle sits left of the theme toggle on both topbar and login.esc()still applies — translations settextContent/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.