Skip to content

Production polish : lifecycle bar, denser pages, reliability sweep and deployment basics - #185

Open
frousselet wants to merge 25 commits into
feat/ui-audit-frameworkfrom
feat/production-polish
Open

frousselet wants to merge 25 commits into
feat/ui-audit-frameworkfrom
feat/production-polish

Conversation

@frousselet

@frousselet frousselet commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

A pass on what made Cairn read as a beta : pages that spent their first screen on air and on a diagram, and a handful of failures that only show up outside a superuser session on a healthy single-process stack.

It is stacked on #184 (it needs the Controls module), hence the base branch. Each commit is one self-contained unit and can be reviewed alone.

Related issue

None.

Type of change

  • Bug fix
  • New feature
  • Refactor / tech debt
  • Documentation
  • Build / CI / tooling

Changes

Interface (feat(ui))

  • Detail pages render the lifecycle bar instead of the full-width graph : one line with the path the record is on, a button named after the transition for each possible move, the exits apart, and a toggle that opens the full graph (drawn on first opening only). The path is read from the schema, so a branch that was not taken is no longer ticked as done.
  • One vertical cadence, the page starting 1.75rem from the top. Page title 2.5rem -> 2rem, record names (over 32 characters) 1.5rem, actions always beside the title. Key figures become a slim strip. The brand guidelines carry the new scale.
  • A list table wider than its card scrolls inside it; its last columns were clipped and unreachable at 1440 px.
  • Sidebar group toggles and links share one size, weight and hover.

Reliability (fix), found by crawling every page as a superuser and as a plain member, and by submitting every form empty and invalid :

  • The dashboard raised for every non-superuser member of a group that allows all scopes.
  • The nonconformity register form crashed when submitted with the Audit source.
  • Every cache call raised when Redis was unreachable; core.cache.ResilientRedisCache degrades to a miss.
  • Lifecycle definitions are cached per worker and were only invalidated in the worker that saved them, while the image runs three. Each worker now revalidates at most every LIFECYCLE_CACHE_TTL seconds.

Performance (perf(lists))

  • Tags, scope ancestors and advanced-filter options are read in a constant number of queries. On the demo dataset : users 416 -> 14, requirements 79 -> 16, action plans 78 -> 22, risk register 71 -> 17, roles 114 -> 18, nonconformities 103 -> 16.

Deployment (feat(ops))

  • GET /health/ (database reachable, no session, any Host), declared as the image HEALTHCHECK.
  • Error pages (400, 403, CSRF, 404, 500) in the product's design, translated, self-contained.
  • Console logging in production, request tracebacks included (LOG_LEVEL).
  • The settings refuse to load with a placeholder SECRET_KEY once DEBUG is off.
  • The maps drew CARTO tiles, which now answer anonymous requests with an "API key required" watermark. The basemap is a setting (MAP_TILE_URL), defaulting to OpenStreetMap.

Accessibility (feat(a11y)), measured with axe-core on the rendered pages :

  • Text reads at 4.5:1 or more in both themes : the muted grey (2.6:1) and every status badge in the light theme, every link in the dark theme (2.7:1) did not. A colour now has a fill and an ink (--accent-text, --success-text...); a custom accent (company, Trust Center) gets its readable tones computed (core/colors.py).
  • The calendar draws an event as a tint and a rule with the title in the text colour.
  • Keyboard : a skip link, one visible focus ring, an href on the fourteen Edit links that had none, buttons to reorder the dashboard tiles without dragging, scrollable tables as focus stops.
  • Names : filter panel fields, grid formsets, dialogs, the selects Tom Select replaces, progress bars.
  • Three checks : contrast recomputed from the tokens (test_contrast.py), the markup of every crawled page (markup_audit), and scripts/a11y_audit.py (axe-core on 92 renderings) in a new CI job.

Operations and hardening (feat(ops), feat(security), perf)

  • manage.py backup / restore : the database and the uploaded files in one archive with a manifest and a checksum per member; the restore verifies it, refuses one from a newer release, saves the current state, loads the dump into a new database that then takes the place of the current one. Tested end to end (SQLite in the suite, PostgreSQL in CI) and by hand in the image : 7 555 records, 412 tables, 6 files identical after a restore.
  • A Content Security Policy on every response : only the instance's own scripts run (inline ones by a per-response nonce), no unsafe-inline, no unsafe-eval. 71 inline scripts carry the nonce, 60 inline handlers became declarative actions. The browser audit fails on any violation.
  • The action log reads the page shown instead of the whole audit trail (170 queries -> 48, and no longer proportional to the history).
  • A group's permission matrix folds by module with its count (5 700 px -> 2 300 px).

Points that deserve a decision

  • Brand guidelines changed : the page title scale and a written vertical cadence (docs/brand/brand-guidelines.md). The guidelines ask for approval before such a change; it is in this PR to be accepted or sent back.
  • SECRET_KEY guard is a breaking change for a misconfigured deployment : an instance running with DEBUG=False and a placeholder key will refuse to start after upgrading.
  • Palette changed for contrast : --text-muted goes from #A1A1AA to #6B6B74, status badges and dark-theme links take darker / lighter inks, and the calendar no longer fills events with their category colour. The guidelines document the fill / ink rule; same approval as above.
  • The accessibility CI job runs on every pull request (about five minutes, in parallel with test). It can be made optional like the PostgreSQL job if that is too much.
  • The maps sent addresses to a third-party geocoder (photon.komoot.io), from the browser, undocumented. It is now a setting (MAP_GEOCODER_URL), still on by default so nothing changes for an existing instance : decide whether the default should be off.
  • The image now carries the PostgreSQL 18 client tools (from the PostgreSQL project's apt repository), needed by the backup commands. They must match the server's major : an instance on another major builds with --build-arg POSTGRES_MAJOR=.
  • The error pages lose their "Go back" button : under the policy it would need a script the 500 page cannot carry.
  • Not done, on purpose : the 230 fixed inline styles stay. They are nearly all one-off values, the policy allows inline styles (a style runs no code), and converting them would trade visual risk for no gain. The inline JavaScript of base.html stays inline too, with a nonce : the policy does not need it moved.
  • Default tile provider : OpenStreetMap's tile service suits moderate use. A deployment with heavy traffic should set MAP_TILE_URL to a provider of its own.

Screenshots

The 35 documentation screenshots under docs/screenshots/ are recaptured at 2560x1440 with scripts/capture_screenshots.py (last commit), so the before / after of every documented screen is the diff of that directory. Light theme, dark theme and a 390 px phone viewport were checked locally on the dashboard, a list, and the risk, incident, control and supplier detail pages.

Checklist

  • Tests added or updated, and pytest passes (3892 passed)
  • ruff check passes
  • New feature exposed as MCP tools in mcp/tools.py (not applicable : no domain feature is added, the health probe and the settings are operational)
  • New feature has REST API endpoints under the app's api/ (not applicable, same reason)
  • UI renders correctly in light and dark mode
  • UI renders correctly on mobile (multi-selects, sticky bars, form layouts)
  • User-facing strings use _() / {% trans %} with French translations in locale/fr/LC_MESSAGES/django.po (no duplicate msgid; compilemessages passes)
  • Lifecycle / workflow respected (state metadata and generic stepper UI; no hardcoded status values)
  • README.md updated (features, MCP tools, tech stack, install) when behaviour changed
  • CHANGELOG.md updated under ## [Unreleased]
  • Brand guidelines respected (docs/brand/brand-guidelines.md); no em dash characters (the guidelines themselves are amended, see above)
  • Relevant spec under docs/specs/ updated in the same PR
  • Project / documentation screenshots captured at 2560x1440 (16:9, 1440p)
  • Audit-grade rigor preserved (approval workflows, versioning, history, permission checks not bypassed)

🤖 Generated with Claude Code

https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV

…t queries

A page of fifty rows issued hundreds of queries, because three things were
read one row or one option at a time :

- the tags printed on every row : SortableListMixin now prefetches `tags`
  for every list whose model carries them;
- the ancestors of each scope in a scope cell : the scope tree is read once
  per request and shared by every cell (context/templatetags/scope_tags.py);
- the relation options of the advanced filter : the registry was built twice
  per request (queryset filter, then page context) and labelled each option
  with str(record), which often reads a parent. It is now built once and the
  mandatory parents of the listed records are joined.

The role list also prefetches its assigned users, and the nonconformity
register its requirements.

Measured on the demo dataset : users 416 -> 14 queries, requirements 79 -> 16,
action plans 78 -> 22, risk register 71 -> 17, roles 114 -> 18,
nonconformities 103 -> 16, issues 102 -> 18.

core/tests/test_list_queries.py compares the cost of a short and a longer
list, so it fails on any per-row query rather than on a hand-tuned ceiling.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
…ility sweep

A crawl of every page as a superuser and as a plain member, plus an empty and
an invalid submission of every form, surfaced these :

- The dashboard raised TypeError for every non-superuser whose group allows
  all scopes : `get_allowed_scope_ids()` returns None for "no restriction" and
  the ongoing-audits query filtered on it. It now goes through
  `filter_queryset_by_scopes` like the other scoped queries.
- The nonconformity register form crashed on submission with the Audit
  source : `Finding.clean()` reports the missing audit on a field the form
  does not carry, which Django turns into a ValueError. The form no longer
  offers that source without an audit (RG-FND-01), and SteppedFormMixin now
  reports any model rule about a field outside the form as a form-level
  error instead of failing.
- Every cache call raised when Redis was unreachable (update check, assistant
  briefing, Trust Center rate limiter). `core.cache.ResilientRedisCache`
  degrades to a miss, logs the outage once a minute, and gets 2 s socket
  timeouts so a silent Redis cannot hold each request.
- `core.settings_local` (Docker-less development) still pointed the cache at
  Redis; it now uses the local-memory backend.

And one that no crawl could show : the lifecycle definitions edited in the
administration are cached per worker process and were only invalidated in the
worker that saved them, while the image runs three. The other two kept
enforcing the previous lifecycle until a restart. Each worker now revalidates
its cache against the table's stamp at most every LIFECYCLE_CACHE_TTL seconds
(5 by default, one aggregate query).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
The interface spent its first screen on air and on a diagram. On a laptop a
detail page showed 130 px of empty space, a title on two lines at 40 px, a
full-width lifecycle graph clipped on its right edge, then a band of tall
key-figure cards : the content started at the bottom of the window. On a
phone the graph alone ran over three screens.

Lifecycle. Every detail page now renders the lifecycle bar : one line with the
steps of the path the record is on (completed, the current one as its status
badge, the steps ahead), a button for each step the user may move to, the
exits apart on the right and a toggle that opens the full directed graph
underneath, drawn on first opening only.

- The path is read from the schema instead of the declaration order : a step
  is completed when the current step is reachable from it along forward
  transitions, so a branch that was not taken is left off the bar instead of
  being ticked.
- A move is a button named after its transition ("Validate", not
  "Validated"), highlighted when forward, quiet for a way back or an exit.
- A lifecycle longer than six steps folds its completed steps to their tick;
  a line still too long scrolls inside the bar, starting at the current step.
- The legacy line / cycle / snake renderers and their CSS are removed; the
  dagre graph stays as the on-demand view and in the lifecycle editor.

Density. One vertical cadence (1.5rem between blocks, 1rem under the header),
the page starting 1.75rem from the top. The page title steps from 2.5rem to
2rem, and a record name (over 32 characters) to 1.5rem; it takes the free
width and wraps inside it, so the actions stay on its right. The detail rail
becomes a slim strip of key figures below 1800 px, two per line on a phone,
and the list key figures tighten the same way. The brand guidelines carry the
new scale and the cadence.

Lists. A table wider than its card spilled under the page edge, where
`overflow-x: clip` hid its last columns with no way to reach them (the
controls and risk registers at 1440 px). It now scrolls inside the card, with
an edge shadow where columns remain.

Sidebar. Group toggles and links share one size, weight, spacing and hover.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
…g basemap

What a deployment could not rely on until now.

Health. `GET /health/` answers 200 or 503 depending on whether the process
can reach the database. It is a middleware placed first in the stack, so a
probe calling by IP with no session is not refused by ALLOWED_HOSTS nor
redirected to the sign-in or onboarding screen, and it discloses nothing. The
image declares it as its HEALTHCHECK. There was no health endpoint before.

Error pages. A missing page, a refused permission, an expired form and an
unhandled error rendered Django's bare text pages. They now render in the
product's design and in the reader's language, from self-contained templates
(no query, no static lookup) so the 500 page survives a database outage.

Logging. Django only logs to the console under DEBUG : in production an
unhandled error left no traceback anywhere, only a 500 line in the access
log. Everything now goes to stderr at LOG_LEVEL, request errors included.

Secret key. With DEBUG off, the settings refuse to load while SECRET_KEY is
one of the two public placeholders (the settings default and the .env.example
value), instead of signing sessions with a key anyone can read.

Maps. The scope, site and supplier pages drew CARTO basemap tiles, and CARTO
now answers every anonymous request with an "API key required" watermark :
the maps were broken for everyone. The provider is now a deployment setting
(MAP_TILE_URL, MAP_TILE_URL_DARK, MAP_TILE_ATTRIBUTION), defaulting to
OpenStreetMap's tile service, with an empty value switching the maps off. The
three copies of the tile code become one helper in base.html, the tiles are
desaturated to stay a backdrop, and dimmed under the dark theme when the
deployment has no dark tiles.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
…ser pages

The 35 images are retaken at 2560x1440 with scripts/capture_screenshots.py on
the demo dataset. Detail pages now show the lifecycle bar instead of the
graph, pages start near the top of the window, and the supplier page shows an
actual map where the previous capture had the tile provider's watermark.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
…whole interface

Two blind spots of the test suite, both documented as accepted until now.

The fast run builds an in-memory SQLite schema from the models, with
migrations switched off. Nothing replayed the 150 migrations a deployment
runs, nothing met the engine it runs on, and nothing noticed a model changed
without its migration. `core.settings_test_postgres` keeps the fast settings
but uses PostgreSQL and real migrations; CI runs the whole suite a second time
with it, after `makemigrations --check`. The suite passes on PostgreSQL 16 as
it stands : this guards what comes next.

Unit tests check what their author thought of. `core/tests/test_site_sweep.py`
checks the rest on the demo dataset : it follows every link from the dashboard
as a superuser, requests the same pages as an administrator who is not a
superuser and as a user with no permission, then submits every create and
edit form empty and with invalid values. No page may answer a server error, no
printed link may be broken. It is the manual sweep that found four server
errors last week, made permanent, and it was checked against the dashboard bug
reintroduced on purpose. It is also the first test that executes the demo
seed, so a schema change that leaves the seed behind now fails.

The sweep is marked `sweep` and takes about 40 s on SQLite.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
…rvice majors

The container ran as root, the settings defaulted to DEBUG, and the compose
file followed `latest` for the database.

Account. The image gains a `cairn` account (uid 1000) that owns /app. The
entrypoint starts as root for one job, handing /app/media and /app/staticfiles
over when they are still root-owned (a media volume written by an earlier
image), then restarts itself with setpriv : no web worker holds root. The
account is the owner of /app, so the development bind-mount keeps generated
files in the host user's name. Started with `--user`, the container runs as
given. Verified on a built image : every process runs as uid 1000, a
root-owned volume is handed over and writable, the healthcheck turns healthy.

DEBUG. Off unless set. An instance started with no configuration served
tracebacks, settings and local variables to whoever triggered an error.
`.env.example` and `core.settings_local` turn it on for development; the test
settings and CI bring a key of their own, since the settings refuse the
placeholder key outside DEBUG.

Versions. `postgres:18` and `redis:8-alpine` : the majors in use today, minor
and patch releases still flowing in. A new PostgreSQL major cannot read the
previous data directory; on `latest`, a routine `docker compose pull` would
one day stop the database from starting. The CI PostgreSQL job runs on 18.

Documentation. The published-image example had no volume for uploaded files,
which lived in the container and were lost on every recreation; it now has
one. It also carried a placeholder SECRET_KEY and PostgreSQL 16 with the
pre-18 data mount.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
…ree suite

The suite printed 1 246 warnings. Two families were defects.

Pagination. Fourteen API lists were paginated over an unordered queryset :
the database is free to return such rows in a different order on each
request, so a page could repeat a record and another record never be listed.
The same holds for any `?ordering=` with ties. `StandardPagination` now gives
every list a total order before cutting it : oldest first when the queryset
has no order, and the primary key appended as the final tie-breaker in all
cases. Querysets that are not plain model lists are left alone.

Dates. The `date_after` / `date_before` filters of the risks API compared a
date-time column with a bare date, read as midnight : `date_before` left out
everything created on the day given. They now compare calendar days in the
active time zone.

The rest was noise, now gone : thirteen factories whose hooks only set
relations stop asking for a second save (ObjectiveFactory keeps it,
explicitly, because its model checks scopes on save), a channel-layer mock
becomes an AsyncMock, and pytest-asyncio gets its loop scope.

`pytest.ini` turns the two defect families into errors so they cannot come
back, and silences the Django 6.1 `EMAIL_*` deprecation with its reason.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
@frousselet

Copy link
Copy Markdown
Owner Author

Progress : safety nets (three commits)

74f26667 test(ci) : the suite now runs a second time on PostgreSQL with every migration replayed, after makemigrations --check, and core/tests/test_site_sweep.py makes the manual crawl permanent (every page as a superuser, as a non-superuser administrator and as a user with no permission; every form submitted empty and invalid). The sweep was checked against the dashboard bug reintroduced on purpose, and is the first test that executes the demo seed.

c6f51151 build(docker) : the container runs as an unprivileged account (uid 1000) after a root hand-over of the writable directories, DEBUG is off unless set, postgres:18 and redis:8-alpine replace latest. Verified on a built image : all processes uid 1000, a root-owned media volume handed over and writable, healthcheck healthy, placeholder key refused. The published-image example in the installation guide gains the media volume it lacked.

06ac9c10 fix(api) : API lists are paginated in a total order (14 lists could repeat and skip rows), the risks date_before filter includes the day given, and the suite goes from 1 246 warnings to none, the two defect families now failing it.

Verification : 3 720 tests pass on SQLite and on PostgreSQL 18, ruff clean, documentation links and generated reference current.

Checklist items covered : tests, ruff, CHANGELOG.md, documentation (docs/technical/, docs/sdk/rest-endpoint.md).

For the reviewer

  • Breaking for a misconfigured deployment : DEBUG now defaults to off, so an instance that relied on the default and kept a placeholder SECRET_KEY will refuse to start.
  • Stack versions : the documentation says Django 5.2 LTS, the unpinned requirements.txt installs Django 6.1, and the image runs Python 3.15 while CI tests on 3.12. This PR does not pin Python packages nor the Python base image (unpinning was a deliberate choice in 2d0baa3c); it only fixes the service majors. Whether to lock dependencies is left open.
  • CI time : the PostgreSQL job takes about 12 minutes on a GitHub runner, the fast job about 5.

@frousselet frousselet added the ci:postgres Run the PostgreSQL test job (migrations replayed) on this pull request label Nov 16, 2026
Since the version pins were removed, every install took the latest release of
everything. The documentation said Django 5.2 LTS; the instance ran Django
6.1, on an image that had moved to Python 3.15 while CI tested on 3.12, an
interpreter Django 5.2 does not support. No two builds of the same commit
were guaranteed to run the same code.

- `requirements.txt` holds the direct dependencies and constrains Django to
  the current LTS line (5.2.x, supported until April 2028).
- `requirements.lock` is the exact set resolved from it, hash-checked, valid
  from Python 3.12 up. The image, CI and the bootstrap script install it.
- The image, the workflows and `mise.toml` name one Python : 3.14, the newest
  the LTS line supports.
- Tests fail if a direct dependency is missing from the lock, if the lock
  leaves the 5.2 line, or if the suite runs on another Django than the locked
  one.

Going back from 6.1 to 5.2.19 was verified before being written : the 3 720
tests pass on SQLite and on PostgreSQL 18 with all 170 migrations replayed
(97 of them generated under Django 6.x), under Python 3.12 and 3.14, and
inside the built image. The framework's own migrations are identical on both
lines, so a database migrated under 6.1 needs nothing. One behaviour is kept
explicitly : a URL typed without a scheme still gets https
(FORMS_URLFIELD_ASSUME_HTTPS).

Found while running the suite inside the image : `.dockerignore` left out
every Markdown file, CHANGELOG.md included, which the dashboard's "what's new"
dialog reads. It never appeared on a published image. CHANGELOG.md, README.md
and LICENSE are back in.

The generated model reference counted fields with a test whose answer depends
on the Django version; it now counts the table's columns.

CI. The PostgreSQL job takes about twelve minutes on a hosted runner. It now
runs on every push to `main`, and on a pull request only with the
`ci:postgres` label or a manual run of the workflow.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
@frousselet

Copy link
Copy Markdown
Owner Author

Progress : dependencies locked on the LTS line (fd5844d3)

Three decisions taken by the maintainer, applied :

  1. Latest LTS. Django is constrained to 5.2.x and everything installs from requirements.lock (exact versions, hash-checked). The image, the workflows and mise.toml share Python 3.14, the newest interpreter Django 5.2 supports. Before this, the image ran Django 6.1 on Python 3.15 while CI tested on 3.12.
  2. DEBUG off by default : confirmed, unchanged.
  3. PostgreSQL job : automatic on main, on a pull request only with the ci:postgres label or a manual run of the workflow. This pull request carries the label, since it changes the framework version.

Verification of the move from 6.1 back to 5.2.19 : 3 720 tests on SQLite and on PostgreSQL 18 with all 170 migrations replayed (97 generated under Django 6.x), under Python 3.12 and 3.14, and inside the built image. The framework's own migrations are identical on both lines.

Also fixed : the published image left CHANGELOG.md out, so the dashboard's "what's new" dialog never appeared there.

Checklist items covered : tests, ruff, README.md, CHANGELOG.md, documentation (docs/technical/).

…at empty means

Detail pages were long for reasons that had nothing to do with their record.
Measured on the demo dataset, card by card, then fixed at the framework level
so every page benefits.

- Traceability was a 270 px card closing every detail page. `record_card` now
  renders it as one line of small print : same data, same place.
- An empty section took 180 to 220 px to say "nothing yet". An empty state
  inside a section card is now always one line under the title.
- `section_card` gains `clamp=True` : with a count, a long table (or a
  `data-clamp-items` list) shows its first eight rows behind a "Show all n"
  button. Applied to a framework's requirements, a risk assessment's analyses
  and risks, and an incident's chronology. A link to a hidden row opens the
  card first.
- An audit folds its requirements by section (foldable table groups). Past
  fifteen rows the sections start folded except the first with work left; what
  the reader opened is kept for the session, so the HTMX refresh after each
  evaluation comes back as it was.
- A page with six sections or more gets a "Jump to a section" menu in its
  header, built from the cards it renders.
- Card padding goes from 2rem / 1.75rem to 1.5rem / 1.25rem.

Heights at 1440 px : framework 7 939 -> 2 781, audit 6 351 -> 3 223, risk
assessment 5 896 -> 3 529, incident 6 024 -> 4 991, risk 3 307 -> 2 736.

Forms. Every empty select opened on Django's row of dashes : a required one
now reads "Choose…", an optional one "None", through the one field partial all
forms render with (39 form pages, now none, and the sweep checks it). On a
phone the step indicator gives its room to the current step's label instead
of cutting three labels to their first letters.

Found on the way : two developer notes written as multi-line `{# #}` comments,
which Django does not treat as comments, were printed in the page (management
review, incident obligations). Fixed, and a test forbids the form.

Dropdown menus use the near-opaque glass, so their items read without relying
on the backdrop blur.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
…ry, fewer queries

Consistency.

- The table standard renders a reference as the clickable `.ref` pill. Eight
  lists added since (incidents, events, notifications, response plans,
  controls, tests, documents, campaigns) used a plain link, so a reference
  looked like one thing in the risk register and another in the next list. A
  test now forbids the plain-link form.
- Tags shown above a record's cards (supplier, site, contract, certificate)
  were centred between the lifecycle bar and the key figures; they align with
  the content.
- A framework listed its requirements in lexicographic order, which the new
  "first rows" view made obvious (A.5.10 right after A.5.1). It uses the
  natural order of the numbers, like the requirements list.

Dashboard.

- Without a written briefing (assistant off, or the model did not answer) the
  summary is one sentence, and the column it had to itself stood empty beside
  the links and the audits. It heads the card and the links take the width.
- Indicator widgets ordered and sliced their measurements in the database,
  discarding the prefetch the dashboard had just done : one query per
  indicator. Risk acceptances were titled with a query per row.

Tag list : usage was counted relation by relation for each tag (396 queries
for the demo dataset). It is one grouped query per tagged model, whatever the
number of tags (71).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
The criteria snapshot of a risk keeps its capture time as an ISO 8601 string
in its JSON, and the risk and ISO 27005 analysis pages printed it raw
(`2026-11-04T10:44:38.610034+00:00`). The new `iso_datetime` filter renders
such a value like every other date-time, in the active locale and time zone.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
Retaken at 2560x1440 with scripts/capture_screenshots.py : the traceability
line, the section menu, the clamped lists and the reference pills of the
incident and controls registers.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
@frousselet

Copy link
Copy Markdown
Owner Author

Progress : shorter screens (four commits)

f7744c91 feat(ui) : detail pages measured card by card, then shortened at the framework level. Traceability becomes one line (record_card), an empty section a line of small print, section_card gains clamp=True (first eight rows behind "Show all n"), an audit folds its requirements by section, and a page with six sections or more gets a "Jump to a section" menu. Heights at 1440 px : framework 7 939 -> 2 781, audit 6 351 -> 3 223, risk assessment 5 896 -> 3 529, incident 6 024 -> 4 991, risk 3 307 -> 2 736. Forms : every empty select reads "Choose…" or "None" instead of a row of dashes (39 form pages), and the step indicator names the current step on a phone.

952708e5 fix(ui) : the eight newer lists show their reference as the same pill as the others (table standard, rule 4), the dashboard summary no longer leaves a column empty without a briefing, a framework lists its requirements in natural order, and the tag list goes from 396 to 71 queries.

1559eab7 fix(risks) : the scoring snapshot's capture time is a date, not a raw ISO string.

320caf70 docs(screenshots) : the 35 screenshots retaken.

Found on the way : two multi-line {# #} comments, which Django does not treat as comments, were printed in the page (management review, incident obligations). A test now forbids the form.

Verification : 3 740 tests pass locally, ruff clean, documentation links resolve; light, dark and phone renderings checked on the changed screens.

Checklist items covered : tests, ruff, light / dark, mobile, translations, CHANGELOG.md, brand guidelines (two form rules added), docs/sdk/ui-components.md, screenshots.

Locking the dependencies stopped updates from arriving on their own, security
releases included. Dependabot now proposes them, one pull request a week per
ecosystem : the Python lock, the patch releases of the image's Python, and the
GitHub Actions.

The lock is renamed so that Dependabot, and GitHub's vulnerability alerts, can
read it. Both only recognise the pip-compile convention : `requirements.in`
holds the direct dependencies, `requirements.txt` the compiled set with its
hashes. Under its previous name (`requirements.lock`) the pinned versions were
invisible to both, and the alerts enabled on the repository had no version to
match an advisory against. The file is compiled with pip-compile rather than
uv for the same reason : it is the format Dependabot knows how to recompile.
Same 84 pins as before on CPython; the image builds from it and the suite
passes.

The configuration leaves the project's decisions alone : Django above the 5.2
LTS line is ignored, and so are minor and major releases of the image's
Python. Python and image updates carry the `ci:postgres` label, so the suite
also runs on PostgreSQL with the migrations replayed. A test keeps those three
rules in place.

Not verifiable before it reaches the default branch : Dependabot only reads
its configuration there.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
@frousselet

frousselet commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner Author

Progress : Dependabot (e3ae6b44)

.github/dependabot.yml proposes weekly updates for the Python lock, the patch releases of the image's Python and the GitHub Actions. It ignores Django above the 5.2 LTS line and minor / major releases of the image's Python, and labels its Python and image pull requests ci:postgres.

The lock is renamed to the pip-compile convention (requirements.in -> compiled requirements.txt), the only form Dependabot and GitHub's vulnerability alerts read. Same pins; the image builds from it and 3 743 tests pass.

Cannot be exercised before it reaches main : Dependabot reads its configuration on the default branch only.

`timezone.now().date()` is the UTC date. In Europe/Paris that is the previous
day for the first hour or two of every local day, and seventeen places used
it (or `date.today()`, the container's date) as "today". During that window :

- an action plan due the day before was not overdue yet, and a plan completed
  then was dated a day early;
- a contract, a certificate or a supplier contract ending that day had not
  expired, and an end-of-life asset was still in service;
- a document reviewed then had its next review computed from the day before;
- the overdue filters of the REST API, an MCP tool, the dashboard and the
  calendar feed counted from the wrong day.

They all use `timezone.localdate()` now, and a stored review time is converted
to local time before its day is taken. The demo seed and the tests take the
same day : seventy-six test expectations were written against the UTC date or
the machine's own, which made them agree with the defect, and would have made
them fail on a UTC runner for part of every evening once the code was right.

It surfaced because a document test ran a few minutes after midnight. The new
tests pin the clock to 00:30 Paris time instead of waiting for it, and one
scans the application code for the two spellings. The whole suite passes
inside that window.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
… apart

The menu had eight sections, sixteen folding groups inside them and about
fifty entries : three levels, two clicks to reach most pages, set-up screens
mixed with the registers people work in, and the same word for two things
("Documents" for the contracts and for the policies). It was also written by
hand twice : as markup in base.html, and as a table for the breadcrumbs.

`core.navigation.MENU` now declares it once. The sidebar (`{% sidebar_menu %}`)
and the breadcrumbs (`NAV_TREE`) are both derived from it.

- Two levels. Seven sections that open on their pages, under the three
  everyday links. No group inside a section, and no heading above one.
- Reference data has its own section : asset groups, supplier types, risk
  criteria, threats, vulnerabilities, requirement mappings, reporting
  authorities and obligation templates. The last two had pages but no menu
  entry at all.
- Controls, their tests, policies and acknowledgement campaigns join
  Compliance instead of being two sections of two and three entries.
- Indicators and Dependencies are one entry each. Their lists are views of
  one subject : each list page gets a row of links to the others under its
  header, limited to the views the reader may open.
- An entry is shown to the users its page lets in. The permission is read
  from the list view itself, so the menu cannot drift from what the page
  enforces. Until now most entries were shown to everyone and bounced back to
  the dashboard with an error.
- The current entry is found by the longest matching URL, so it stays marked
  on the records of its register (nothing was marked on a detail page), and
  its section carries a mark of its own when folded or in the icon rail.

Page addresses do not change. Breadcrumbs lose a level : Governance > Scopes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
Retaken at 2560x1440 with scripts/capture_screenshots.py : every screen shows
the sidebar, so every image changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
@frousselet

Copy link
Copy Markdown
Owner Author

Progress : navigation, and a date bug found on the way (three commits)

3f1cf39a feat(nav) : the sidebar goes from three levels to two. core.navigation.MENU declares the navigation once; the sidebar and the breadcrumbs are both derived from it (the menu was hand-written in base.html and mirrored by hand for the breadcrumbs).

  • Seven sections that open on their pages, under the three everyday links.
  • Reference data (types, criteria, catalogs, mappings, authorities, templates) in a section of its own.
  • Controls, tests, policies and campaigns join Compliance.
  • Indicators and Dependencies are one entry each, with a view switcher on their list pages.
  • An entry is shown to the users its page lets in (the permission is read from the list view), and stays marked on the records of its register.

Page addresses do not change.

214f55ad fix : "today" was the UTC date in seventeen places, so for the first hours of each local day overdue plans, expired contracts and certificates and document review dates were a day behind. It surfaced because a test ran a few minutes after midnight. The tests now pin the clock to 00:30 Paris time, and 76 test expectations written against the UTC date were aligned.

98edae6e docs(screenshots) : the 35 screenshots retaken (the sidebar is on each).

Verification : 3 760 tests pass, including the interface sweep on the new menu; ruff clean; documentation links resolve; light, dark, phone and icon-rail renderings checked.

Checklist items covered : tests, ruff, light / dark, mobile, translations, CHANGELOG.md, user guide and SDK pages, screenshots.

@frousselet

frousselet commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner Author

Progress : accessibility (two commits)

2802d940 feat(a11y) : the guidelines claimed WCAG 2.2 AA; an axe-core audit of the rendered pages found about 1 900 failing elements over 33 pages in the light theme and over 1 100 contrast failures over 22 pages in the dark one, nearly all from four causes.

  • Contrast. The muted grey (2.6:1) and the status badges in the light theme, every link in the dark theme (navy on charcoal, 2.7:1), white text on the calendar's category colours. A colour now has a fill token and an ink token; text uses the ink. A custom accent colour (company settings, Trust Center) has its readable tones computed.
  • Keyboard. A skip link; one focus ring that stands out; fourteen Edit links had no href and could not be reached; dashboard tiles get buttons that do what dragging does; a table that scrolls sideways is a focus stop.
  • Names. Filter panel fields, grid formsets, form dialogs, the native selects Tom Select replaces, progress bars, the mobile menu button.
  • Checks. test_contrast.py recomputes every ratio from the tokens; the interface sweep parses every page (it found 113 defects in closed panels that a browser audit skips); scripts/a11y_audit.py runs axe-core on 92 renderings (both themes, an open dialog and filter panel, four pages at a phone's width) in a new CI job. Its instance is built from the models and seeded in seconds; a page that does not render fails the audit.

Found on the way : on a phone, the rows of the dashboard's progress-bar tiles collapsed onto each other; the framework tile read "90 requirement".

feabc131 docs(screenshots) : the 35 screenshots retaken on the new palette. The capture script now emulates the light theme, so the set no longer depends on the machine it is captured on.

Verification : 3 829 tests pass; ruff clean; a11y_audit.py reports no WCAG 2.2 A/AA violation across 92 renderings on a freshly seeded instance; documentation links resolve.

Not covered, said plainly : the manual sort order of a progress-bar tile and the tasks board are still drag-only (the board's moves can be made from each record's page); modal titles are h5 (an axe best-practice remark, not a WCAG failure); no test with a real screen reader was done.

Checklist items covered : tests, ruff, light / dark, mobile, translations, README.md, CHANGELOG.md, brand guidelines (amended, see the decision points), specs, screenshots.

…e checks that hold it

The guidelines claimed WCAG 2.2 AA; an axe-core audit of the rendered pages
said otherwise. In the light theme the muted grey (#A1A1AA, 2.6:1) carried
table headers, labels and sub-lines, and every status badge was under 4.5:1.
In the dark theme every link was navy on charcoal (2.7:1). Fourteen Edit
buttons could not be reached from the keyboard.

Contrast
- `--text-muted` is the lightest grey that carries text (5.3:1 light, 5.1:1
  dark); lighter greys are for borders.
- A colour has a fill and an ink. The fill (`--accent`, `--success`...) stays
  for dots, bars and buttons; text uses the ink (`--accent-text`,
  `--success-text`...), which clears 4.5:1 on the surfaces and on its own
  soft background. 175 text uses moved to the ink tokens.
- The calendar draws an event as a tint and a rule in its category colour
  with the title in the text colour : half of its twelve hues could not carry
  white text.
- A colour typed by an administrator stays readable (`core/colors.py`) : the
  company accent gets an ink per theme and a label that reads on it; the
  Trust Center banner deepens the accent until its white text reads, and its
  links were unreadable on the dark theme.
- Placeholders lose their transparency; the focus ring is one neutral token
  at 3:1 or more, replacing pale halos.

Keyboard and screen readers
- A skip link, named landmarks, card titles as h2 on the dashboard.
- Acting links keep an href beside their hx-get; a day with events in the
  calendar's year view is a button; dashboard tiles get Move earlier / Move
  later buttons, the keyboard's equivalent of the drag.
- Controls are named : filter panel fields, grid formsets
  (`LabelledRowsFormSet`), the mobile menu button, calendar arrows, progress
  bars. A dialog filled over HTMX is named after its title, the native select
  Tom Select replaces leaves the screen reader's tree, and a table that
  scrolls sideways becomes a focus stop.
- A collapsible card renders its actions beside the summary, not inside it.

Checks
- `core/tests/test_contrast.py` recomputes every text / surface ratio from
  the tokens, in both themes, and refuses a fill token used as text.
- The interface sweep parses every page (`markup_audit`) for an image without
  alt, a control without a name, a link without href, a field without a
  label. It found 113 defects in closed panels a browser audit skips.
- `scripts/a11y_audit.py` runs axe-core on 92 renderings : the screenshot set
  in both themes, an open dialog and filter panel, four pages at a phone's
  width. A new CI job seeds a demo instance and runs it on every push.

Found on the way : on a phone the rows of the dashboard's progress-bar tiles
collapsed onto each other (the stacked rule lost to a later one of equal
specificity), and the framework tile read "90 requirement".

The audit instance is a throwaway SQLite file (`SQLITE_PATH`) whose schema is
built from the models (`SCHEMA_FROM_MODELS`) : replaying every migration on
SQLite took nine of the job's thirteen minutes. The reference rows the data
migrations write come from `accounts.reference_data`, which the test suite's
fixture now shares. A page that does not render fails the audit.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
Retaken at 2560x1440 from a freshly seeded demo instance : the muted text,
the status badges and the calendar change on every screen.

The capture script now emulates the light theme (`--theme`, light by
default). Headless Chrome follows the machine's theme, so the set came out
dark on a machine set to dark mode.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
@frousselet
frousselet force-pushed the feat/production-polish branch from 71c258b to feabc13 Compare November 17, 2026 07:35
The action log merges the history table of every audited model (88 of them).
It did so by loading every row of every table and sorting them in Python on
each visit, then handing the list to the paginator : the cost of opening the
page was the size of the audit trail, which only grows.

`MergedHistory` is a lazy sequence the paginator slices. A page costs one
UNION ALL over the tables for its keys (ordered and limited by the database,
which walks each table's history_date index), one query per table present on
the page for the rows, and one count. Rows saved at the same instant are
ordered by table and id, so a row cannot land on two pages or on none.

A row was also classified (creation, update, transition, deletion) with one
query for its previous version. The rows now come with the previous lifecycle
state attached by a subquery; `entry_kind` gives the same answer as
`classify_record`, checked on 1 250 rows of the demo dataset.

On the demo dataset the page goes from 170 queries to 48, the remainder being
the related records each row names. The site list also prefetches its tags.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
The documented backup was two shell lines (pg_dump, tar) and the sentence
"test the restore". Nothing checked that the two halves belonged together,
that the archive was readable, or that a restore worked.

`manage.py backup` writes the database and MEDIA_ROOT into one tar archive
with a manifest : format, Cairn version, engine and server version, applied
migrations, size and SHA-256 of every member. It reads the archive back and
verifies it before reporting success. `--keep N` rotates.

`manage.py restore` puts an instance back in the exact state of an archive :
- every member is verified against the manifest first;
- an archive made by a newer release is refused (its schema has migrations
  this code does not know); an older one reports what is left to migrate;
- the current state is saved beside the archive before anything is replaced;
- the dump is loaded into a new database that then takes the name of the
  current one, so a dump that fails to load leaves the current database as it
  was; the application's sessions are closed for the swap;
- the media directory is replaced by the archive's files, extracted beside
  the live ones first. `--check` verifies and changes nothing.

The first design reloaded in place, inside one transaction. Tried on a real
instance (412 tables), it exhausted the server's lock table : dropping and
recreating a few hundred tables in a single transaction needs more locks than
max_locks_per_transaction allows by default. It failed cleanly, which is how
the load-beside-then-swap design came about.

The client tools must be of the server's major (pg_dump refuses a newer
server, a newer pg_restore writes statements an older server rejects) : the
commands check it, the image now ships postgresql-client-18, and a test keeps
the Dockerfile, the compose file and the CI job on the same major.

Tested end to end on SQLite in the default suite (a throwaway instance is
backed up, damaged, restored and compared), and on PostgreSQL in the CI job :
exact restore, repeated restore, a truncated dump, a restore while a session
is open, a role without CREATEDB. Verified by hand in the image on the demo
dataset : 7 555 records, 412 tables and 6 files identical after the restore.

MEDIA_ROOT and BACKUP_DIR are settable from the environment.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
@frousselet

frousselet commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner Author

Progress : operations and front-end hardening (three commits)

46746dc4 perf(action-log) : the action log loaded every row of every history table (88 of them) into memory and sorted them in Python on each visit. It now asks the database for the page shown : one UNION ALL for the keys, one query per table on the page, one count. 170 queries -> 48 on the demo dataset, and the cost no longer follows the size of the audit trail. Classification checked identical on 1 250 rows.

815fd075 feat(ops) : manage.py backup writes the database and MEDIA_ROOT into one archive with a manifest and a SHA-256 per member, and verifies it. manage.py restore verifies the archive, refuses one made by a newer release, saves the current state, loads the dump into a new database that then takes the place of the current one, and replaces the media files.

  • The first design reloaded in place in one transaction. Tried on a real instance (412 tables) it exhausted PostgreSQL's lock table and failed (cleanly). Hence the load-beside-then-swap design.
  • Verified in the image on the demo dataset : 7 555 records, 412 tables and 6 files identical after backup, damage and restore.
  • Tested end to end on SQLite in the default suite and on PostgreSQL in CI (exact restore, repeated restore, truncated dump, restore while connected, role without CREATEDB). The image ships postgresql-client-18; the tools must be of the server's major.

9eacd679 feat(security) : every response carries a Content Security Policy. Only the instance's own script files and the inline scripts carrying the response's nonce run : no unsafe-inline, no unsafe-eval.

  • 71 inline scripts carry the nonce; 60 inline event handlers became declarative actions (data-on-click, static/js/cairn/actions.js); htmx evaluates nothing.
  • Found on the way : the maps sent the address of a site or supplier to photon.komoot.io from the browser, hard-coded, while the README said the tiles were the only outside call. Now a setting (MAP_GEOCODER_URL), documented, switched off by an empty value.
  • Found on the way : refusing an OAuth consent redirected to the address in the form before validating it.
  • The browser audit now fails on any policy violation or script error : 96 renderings clean.

Verification : 3 889 tests pass; ruff clean; the PostgreSQL job ran the backup tests (none skipped).

Not applicable to these commits : MCP tools and REST endpoints (backup and restore are operator commands; exposing a restore over an API would be a risk, not a feature).

Checklist items covered : tests, ruff, light / dark, translations, README.md, CHANGELOG.md (with ### Security), specs and technical docs, audit-grade rigor.

@frousselet

frousselet commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner Author

Progress : the permission matrix

ac41c1a8 feat(ui) : a group's permissions were ten tables one under the other, 5 700 px of checkboxes. Each module is now a folded native <details> whose header shows how many of its permissions the group holds (12 / 40), updated as boxes are ticked. Expand all opens every module. The page is 2 300 px tall. A folded module's checkboxes remain part of the form, which a test pins : saving never depends on what is open.

Also : a table that scrolls sideways is named after its section; the user chip follows the accent's contrast colour; the browser audit visits a group's page.

Verification : 3 892 tests pass; ruff clean; browser audit clean on the group page in both themes, folded and expanded.

Checklist items covered : tests, ruff, light / dark, mobile, translations, CHANGELOG.md, spec (m0-accounts), user guide.

…'s own scripts

Pages were served with no Content Security Policy : a script that reached a
page (a field that escaped sanitising, a tampered record) ran with the user's
session. Every response now carries one (`core/csp.py`) :

    default-src 'self'; script-src 'self' 'nonce-<random>';
    style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: <tiles>;
    connect-src 'self' ws(s)://<host> <geocoder>; object-src 'none';
    base-uri 'self'; form-action 'self'; frame-ancestors 'none'

A script runs when it is one of the instance's static files or carries the
nonce of its response. No 'unsafe-inline', no 'unsafe-eval'. To get there :

- The 71 inline scripts carry `nonce="{% csp_nonce %}"`. It is a tag, not a
  context variable : a form widget and an inclusion tag are rendered with a
  context of their own, where a variable would be empty and the script
  refused (the scope picker on a full-page form, the help dialog). The tag
  reads the request being answered. htmx gives the scripts of a swapped
  fragment the page's nonce and evaluates nothing (`allowEval` off); the one
  `hx-on` attribute became a listener.
- The 60 inline event handlers are gone. An element names an action
  registered in `window.cairnActions` (`data-on-click="..."`, `data-arg`),
  dispatched by `static/js/cairn/actions.js`; `data-confirm` replaces
  `return confirm(...)`. Only a registered function can be named, so markup
  cannot reach an arbitrary global.
- The error pages lose their "Go back" button : the 500 page is rendered with
  no context and could carry no nonce.
- The OAuth consent page drops `form-action` (its form is answered by a
  redirect to the client), and its refusal now checks the redirect address
  before using it, as its approval did.
- The legacy `stepper` component, unused since the lifecycle bar and holding
  two of the handlers, is removed.

Styles stay allowed inline : a style runs no code, and Bootstrap, Tom Select,
Leaflet and ECharts position elements with style attributes.

Writing the policy showed that the maps sent the address of a site or a
supplier to photon.komoot.io from the reader's browser, hard-coded in three
templates and in the address type-ahead, while the README said the tiles were
the only outside call. It is now a setting (`MAP_GEOCODER_URL`), listed in
the policy, documented, and switched off by an empty value.

`CSP_MODE` (enforce, report, off) is the escape hatch for an instance behind
a proxy that rewrites pages.

Checked three ways. `core/tests/test_csp.py` reads the header and scans every
template (no handler, no script without its nonce, no `hx-on`, every named
action registered). The markup audit of the sweep refuses a handler on any
rendered page. The browser audit now fails on any policy violation or script
error a browser reports : 96 renderings clean, after confirming by hand that
an injected script and an injected handler are refused, and that boosted
navigation, dialogs, the calendar, the dependency graph and the permission
presets still work.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
A group's page listed its permissions as ten tables one under the other : a
few hundred checkboxes, 5 700 px of form, and no way to see what the group
can do without reading all of it.

Each module is now a folded section (a native <details>, so the keyboard
folds it) whose header shows how many of its permissions the group holds,
`12 / 40`, kept current as boxes are ticked and green when the module is
granted in full. "Expand all" opens every module. The module's "Select all"
sits under its header rather than inside it (a control inside a summary is a
control inside a control). The page is 2 300 px tall.

A folded module's checkboxes are still part of the form : saving applies the
whole matrix whatever is open, which a test pins.

Also :
- a table that scrolls sideways is named after the section it sits in, so
  the modules' tables do not all announce themselves as "Permissions";
- the user chip takes the accent's contrast colour instead of a hard-coded
  white, which a pale custom accent could not carry;
- the browser audit visits a group's page.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
@frousselet
frousselet force-pushed the feat/production-polish branch from 5ad4098 to bf3c937 Compare November 17, 2026 09:30
@frousselet

frousselet commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner Author

Progress : a defect the audit could not see, and the audit fixed

The PostgreSQL job failed on the policy commit : on a migrated database, the help dialog's script was rendered with an empty nonce, so a browser would have refused it on every real instance. The browser audit had passed.

Cause. The nonce was a template context variable. A form widget and an inclusion tag are rendered with a context of their own, where it is empty. Fix (folded into 9eacd679, the policy commit, rewritten) : {% csp_nonce %} is a tag that reads the request being answered, whatever renders the template. Two tests reproduce the failure (the help dialog, the scope picker on a full-page form), and the 27 policy tests pass on PostgreSQL with the real migrations.

Why the audit missed it (2e50e961 ci(audit)) : its instance was built straight from the models to save time, so it had no help content, which comes from a data migration. The job now migrates a PostgreSQL service and seeds it : the instance a deployment serves. Replaying the migrations takes seven minutes on a runner, so the migrated, still empty database is cached as a dump keyed on the migration files, and migrate runs after a restore too. The audit also opens a form as a page of its own, which found the scope picker's 14 px touching targets (now 24 px).

Verification : 3 897 tests pass on SQLite; the policy, accessibility and action-log tests pass on PostgreSQL with migrations; browser audit clean on 98 renderings of the migrated instance.

The browser audit ran on a database built straight from the models, to spare
the nine minutes SQLite takes to replay the migrations. The help content, the
default lifecycles and the reference data are written by data migrations, so
that instance had none of them : it was not the instance a deployment serves.
The policy commit went through it with the help dialog's script being refused
on every real instance; the PostgreSQL test job is what caught it.

The job now migrates a PostgreSQL service (`LOCAL_POSTGRES=1` keeps the main
settings' database under the local settings), seeds it and serves it. The
model-built SQLite instance stays documented for a quick local look, with its
blind spot stated.

Replaying the migrations takes seven minutes on a runner, so the migrated,
still empty database is cached as a dump keyed on the content of every
migration file. `migrate` runs after a restore as after a miss, finds nothing
to apply and fires the post-migrate hooks : the instance is still the product
of the migrations, not of a shortcut around them.

The audit also opens a form as a page of its own, whose scope picker is a
form widget rendered outside the page's template context. That page showed
the picker's fold button and checkboxes were 14 px targets touching each
other : they are 24 px, or keep 24 px clear (WCAG 2.5.8).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
@frousselet
frousselet force-pushed the feat/production-polish branch from bf3c937 to 2e50e96 Compare November 17, 2026 09:56
A review of the MCP sign-in flow, asked for with "security first", found that
its tokens were not tied to a person.

An access token belonged to its application and acted as the owner of that
application. A public client (dynamic registration, authorization code) is
owned by whoever authorizes it first, and shared by everyone who authorizes it
after : the second user to approve a client received a token acting as the
first. With a desktop client, whose redirect address is on the loopback
interface, anyone who knew a client id (it is not a secret) and had an account
of their own could obtain a token for the account that first connected that
client, an administrator's included.

- A token carries its user : the person who consented, or the owner of the
  application for client credentials. The code already recorded who
  consented; the token endpoint ignored it.
- Migration 0004 deletes the tokens issued to public clients, since nothing
  recorded tells which of them act as someone else, and attaches the others to
  their application's owner. The users of a public client approve it again.

Around it :

- Registration is open to anyone and accepted any redirect address, including
  none, in which case consent then accepted any address at all. It requires
  one to ten addresses : https, http on the loopback interface, or an
  installed application's private scheme; no fragment, no credentials, no
  scheme the browser interprets. A code only goes to an exact registered
  address, and an application that registered none has no code flow.
- The consent screen shows the address that will receive the access, not only
  the name the application chose for itself, and is offered only to accounts
  allowed to use MCP.
- Tokens never expired. They live OAUTH_ACCESS_TOKEN_LIFETIME_DAYS (90 by
  default) and say so (`expires_in`); the existing ones are brought back to
  that lifetime.
- The two open endpoints are rate limited, an authorization code is spent by
  an atomic update, secrets and PKCE challenges are compared in constant time,
  and a registered client is always public.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEkJkxoxKbGMSYquC2dwV
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:postgres Run the PostgreSQL test job (migrations replayed) on this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants